setOriginPathname() — astro Function Reference
Architecture documentation for the setOriginPathname() function in rewrite.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD e64f9687_bb03_7adc_d418_47affefd6f46["setOriginPathname()"] 67024343_d7f2_f928_d5b2_367cfa846343["rewrite.ts"] e64f9687_bb03_7adc_d418_47affefd6f46 -->|defined in| 67024343_d7f2_f928_d5b2_367cfa846343 style e64f9687_bb03_7adc_d418_47affefd6f46 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/routing/rewrite.ts lines 191–217
export function setOriginPathname(
request: Request,
pathname: string,
trailingSlash: AstroConfig['trailingSlash'],
buildFormat: AstroConfig['build']['format'],
): void {
// Handle undefined pathname
if (!pathname) {
pathname = '/';
}
// Apply trailing slash logic based on configuration
const shouldAppendSlash = shouldAppendForwardSlash(trailingSlash, buildFormat);
let finalPathname: string;
// Special handling for root path
if (pathname === '/') {
// Root path always keeps the slash
finalPathname = '/';
} else if (shouldAppendSlash) {
finalPathname = appendForwardSlash(pathname);
} else {
finalPathname = removeTrailingForwardSlash(pathname);
}
Reflect.set(request, originPathnameSymbol, encodeURIComponent(finalPathname));
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does setOriginPathname() do?
setOriginPathname() is a function in the astro codebase, defined in packages/astro/src/core/routing/rewrite.ts.
Where is setOriginPathname() defined?
setOriginPathname() is defined in packages/astro/src/core/routing/rewrite.ts at line 191.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free