getPattern() — astro Function Reference
Architecture documentation for the getPattern() function in pattern.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD f354bedf_10d5_4cb7_90f2_ccd0810481ae["getPattern()"] 341b1026_6b09_5d29_5fc3_f56443492092["pattern.ts"] f354bedf_10d5_4cb7_90f2_ccd0810481ae -->|defined in| 341b1026_6b09_5d29_5fc3_f56443492092 b305ae39_dc2b_c368_dc79_efce7e04dcd4["getTrailingSlashPattern()"] f354bedf_10d5_4cb7_90f2_ccd0810481ae -->|calls| b305ae39_dc2b_c368_dc79_efce7e04dcd4 style f354bedf_10d5_4cb7_90f2_ccd0810481ae fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/routing/manifest/pattern.ts lines 4–45
export function getPattern(
segments: RoutePart[][],
base: AstroConfig['base'],
addTrailingSlash: AstroConfig['trailingSlash'],
) {
const pathname = segments
.map((segment) => {
if (segment.length === 1 && segment[0].spread) {
return '(?:\\/(.*?))?';
} else {
return (
'\\/' +
segment
.map((part) => {
if (part.spread) {
return '(.*?)';
} else if (part.dynamic) {
return '([^/]+?)';
} else {
return part.content
.normalize()
.replace(/\?/g, '%3F')
.replace(/#/g, '%23')
.replace(/%5B/g, '[')
.replace(/%5D/g, ']')
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
})
.join('')
);
}
})
.join('');
const trailing =
addTrailingSlash && segments.length ? getTrailingSlashPattern(addTrailingSlash) : '$';
let initial = '\\/';
if (addTrailingSlash === 'never' && base !== '/') {
initial = '';
}
return new RegExp(`^${pathname || initial}${trailing}`);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getPattern() do?
getPattern() is a function in the astro codebase, defined in packages/astro/src/core/routing/manifest/pattern.ts.
Where is getPattern() defined?
getPattern() is defined in packages/astro/src/core/routing/manifest/pattern.ts at line 4.
What does getPattern() call?
getPattern() calls 1 function(s): getTrailingSlashPattern.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free