matchPathname() — astro Function Reference
Architecture documentation for the matchPathname() function in remote.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD e4d6b9d5_a708_a09a_a75b_8c97ce8d3630["matchPathname()"] be14f71c_abe1_1789_62c6_249b28c23bcc["remote.ts"] e4d6b9d5_a708_a09a_a75b_8c97ce8d3630 -->|defined in| be14f71c_abe1_1789_62c6_249b28c23bcc 2c106453_076d_2939_b71b_64bda08efedf["matchPattern()"] 2c106453_076d_2939_b71b_64bda08efedf -->|calls| e4d6b9d5_a708_a09a_a75b_8c97ce8d3630 style e4d6b9d5_a708_a09a_a75b_8c97ce8d3630 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/internal-helpers/src/remote.ts lines 85–103
export function matchPathname(url: URL, pathname?: string, allowWildcard = false): boolean {
if (!pathname) {
return true;
} else if (!allowWildcard || !pathname.endsWith('*')) {
return pathname === url.pathname;
} else if (pathname.endsWith('/**')) {
const slicedPathname = pathname.slice(0, -2); // ** length
return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
} else if (pathname.endsWith('/*')) {
const slicedPathname = pathname.slice(0, -1); // * length
const additionalPathChunks = url.pathname
.replace(slicedPathname, '')
.split('/')
.filter(Boolean);
return additionalPathChunks.length === 1;
}
return false;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does matchPathname() do?
matchPathname() is a function in the astro codebase, defined in packages/internal-helpers/src/remote.ts.
Where is matchPathname() defined?
matchPathname() is defined in packages/internal-helpers/src/remote.ts at line 85.
What calls matchPathname()?
matchPathname() is called by 1 function(s): matchPattern.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free