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
.ctor
#public LinkVerificationService(
IEnumerable<ContentRoute> knownRoutes,
IEnumerable<string>? copiedAssetPaths = null,
string baseUrl = "/");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.
Parameters
knownRoutesIEnumerable<ContentRoute>copiedAssetPathsIEnumerable<string>? (optional)baseUrlstring (optional)
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
{
/// 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.
public LinkVerificationService(
IEnumerable<ContentRoute> knownRoutes,
IEnumerable<string>? copiedAssetPaths = null,
string baseUrl = "/");
/// 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);
/// Verify all links found in a page's rendered HTML.
public ImmutableList<LinkCheckResult> VerifyLinks(ContentRoute sourcePage, string html);
}