This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

BaseUrlHtmlRewriter Pennington.Infrastructure

Prefixes root-relative URLs (href, src, action) with the configured base URL. Also stamps data-base-url on <body> so client-side code can reproduce the same prefix on dynamically-generated links.

Outermost transport layer — Order 30, so xref (10) and locale rewriting (20) both operate on logical root-relative paths without having to strip the base URL first.

Properties

Order int
Sort order within the HTML rewriting pipeline. Rewriters run in ascending Order. Xref resolution at 10, locale prefixing at 20, base-URL prefixing at 30 — the outside-in order that was previously expressed across separate IResponseProcessors.

Constructors

.ctor

#
public BaseUrlHtmlRewriter(OutputOptions? outputOptions);

Initializes the rewriter with the base URL from OutputOptions.

Parameters

outputOptions OutputOptions?

Methods

ApplyAsync

#
public Task ApplyAsync(IDocument document, HttpContext context);

Mutate the shared parsed document. The orchestrator serializes it once after every rewriter has run.

Parameters

document IDocument
context HttpContext

Returns

Task

ShouldApply

#
public bool ShouldApply(HttpContext context);

Cheap gate checked before parsing. Return false to skip both PreParseAsync and ApplyAsync for this response. If every rewriter returns false, the orchestrator skips parsing entirely.

Parameters

context HttpContext

Returns

bool

Pennington.Infrastructure.BaseUrlHtmlRewriter

namespace Pennington.Infrastructure;

/// Prefixes root-relative URLs (href, src, action) with the configured base URL. Also stamps data-base-url on <body> so client-side code can reproduce the same prefix on dynamically-generated links. Outermost transport layer — Order 30, so xref (10) and locale rewriting (20) both operate on logical root-relative paths without having to strip the base URL first.
public class BaseUrlHtmlRewriter
{
    /// Initializes the rewriter with the base URL from OutputOptions.
    
public BaseUrlHtmlRewriter(OutputOptions? outputOptions);
/// Mutate the shared parsed document. The orchestrator serializes it once after every rewriter has run.
public Task ApplyAsync(IDocument document, HttpContext context);
/// Sort order within the HTML rewriting pipeline. Rewriters run in ascending Order. Xref resolution at 10, locale prefixing at 20, base-URL prefixing at 30 — the outside-in order that was previously expressed across separate IResponseProcessors.
public int Order => 30;
/// Cheap gate checked before parsing. Return false to skip both PreParseAsync and ApplyAsync for this response. If every rewriter returns false, the orchestrator skips parsing entirely.
public bool ShouldApply(HttpContext context);
}