LinkVerificationService
Pennington.Infrastructure
Verifies internal links in rendered HTML against known routes. Extracts href and src attributes and classifies each as valid, broken, or external. Does not make HTTP requests — this is purely static analysis.
Constructors
LinkVerificationService
#public LinkVerificationService(IEnumerable<ContentRoute> knownRoutes, IEnumerable<string> copiedAssetPaths = null, string baseUrl = "/", IEnumerable<ArtifactClaim> artifactClaims = null)
Create with the set of all known page canonical paths, the static asset paths the engine copied into the output tree, and the base URL the surrounding site was rendered with. The base URL is used to strip a common prefix (e.g. /preview) from extracted hrefs before comparing against the unprefixed canonical CanonicalPath, and before applying the framework-asset prefix check for /_content/ / /_framework/ / /_blazor/. Passing "/" (the default) disables prefix stripping. copiedAssetPaths are relative output paths produced by GetContentToCopyAsync (e.g. media/sample.svg); they get normalized into absolute root-relative URLs (/media/sample.svg) and added to the known-paths set so that <img src> references to assets the engine just copied aren't flagged as broken. artifactClaims are the artifact tier's declared URL territories: a link landing inside one is treated as valid without per-path verification, because the exact artifact set is lazy and may not be enumerable on the request path. Build-mode callers that enumerate exact artifact routes into knownRoutes should pass no claims, so typos inside a claimed territory still get flagged.
Parameters
knownRoutesIEnumerable<ContentRoute>copiedAssetPathsIEnumerable<string>baseUrlstringartifactClaimsIEnumerable<ArtifactClaim>
Methods
FindLinksWithoutTrailingSlash
#public static ImmutableList<string> FindLinksWithoutTrailingSlash(string html)
Find internal page links in HTML that are missing a trailing slash. Returns the list of offending URLs.
Parameters
htmlstring
Returns
ImmutableList<string>VerifyLinks
#public ImmutableList<LinkCheckResult> VerifyLinks(ContentRoute sourcePage, string html)
Verify all links found in a page's rendered HTML.
Parameters
sourcePageContentRoutehtmlstring
Returns
ImmutableList<LinkCheckResult>Pennington.Infrastructure.LinkVerificationService
namespace Pennington.Infrastructure;
/// Verifies internal links in rendered HTML against known routes. Extracts href and src attributes and classifies each as valid, broken, or external. Does not make HTTP requests — this is purely static analysis.
public class LinkVerificationService
{
/// Find internal page links in HTML that are missing a trailing slash. Returns the list of offending URLs.
public static ImmutableList<string> FindLinksWithoutTrailingSlash(string html)
;
/// Create with the set of all known page canonical paths, the static asset paths the engine copied into the output tree, and the base URL the surrounding site was rendered with. The base URL is used to strip a common prefix (e.g. /preview) from extracted hrefs before comparing against the unprefixed canonical CanonicalPath, and before applying the framework-asset prefix check for /_content/ / /_framework/ / /_blazor/. Passing "/" (the default) disables prefix stripping. copiedAssetPaths are relative output paths produced by GetContentToCopyAsync (e.g. media/sample.svg); they get normalized into absolute root-relative URLs (/media/sample.svg) and added to the known-paths set so that <img src> references to assets the engine just copied aren't flagged as broken. artifactClaims are the artifact tier's declared URL territories: a link landing inside one is treated as valid without per-path verification, because the exact artifact set is lazy and may not be enumerable on the request path. Build-mode callers that enumerate exact artifact routes into knownRoutes should pass no claims, so typos inside a claimed territory still get flagged.
public LinkVerificationService(IEnumerable<ContentRoute> knownRoutes, IEnumerable<string> copiedAssetPaths = null, string baseUrl = "/", IEnumerable<ArtifactClaim> artifactClaims = null)
;
/// Verify all links found in a page's rendered HTML.
public ImmutableList<LinkCheckResult> VerifyLinks(ContentRoute sourcePage, string html)
;
}