matchHostname() — astro Function Reference
Architecture documentation for the matchHostname() function in remote.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 61517f52_0061_a7c8_31ee_a33231f85f7a["matchHostname()"] be14f71c_abe1_1789_62c6_249b28c23bcc["remote.ts"] 61517f52_0061_a7c8_31ee_a33231f85f7a -->|defined in| be14f71c_abe1_1789_62c6_249b28c23bcc 2c106453_076d_2939_b71b_64bda08efedf["matchPattern()"] 2c106453_076d_2939_b71b_64bda08efedf -->|calls| 61517f52_0061_a7c8_31ee_a33231f85f7a 7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0["isRemoteAllowed()"] 7d71a8a1_3fbe_5f98_fd7b_39e56b5f23b0 -->|calls| 61517f52_0061_a7c8_31ee_a33231f85f7a style 61517f52_0061_a7c8_31ee_a33231f85f7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/internal-helpers/src/remote.ts lines 54–75
export function matchHostname(url: URL, hostname?: string, allowWildcard = false): boolean {
if (!hostname) {
return true;
} else if (!allowWildcard || !hostname.startsWith('*')) {
return hostname === url.hostname;
} else if (hostname.startsWith('**.')) {
const slicedHostname = hostname.slice(2); // ** length
return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
} else if (hostname.startsWith('*.')) {
const slicedHostname = hostname.slice(1); // * length
// Check if url hostname ends with the base domain
if (!url.hostname.endsWith(slicedHostname)) {
return false;
}
// Extract the subdomain part (before the base domain, excluding the dot)
const subdomainWithDot = url.hostname.slice(0, -(slicedHostname.length - 1));
// Should be exactly one subdomain part followed by a dot
return subdomainWithDot.endsWith('.') && !subdomainWithDot.slice(0, -1).includes('.');
}
return false;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does matchHostname() do?
matchHostname() is a function in the astro codebase, defined in packages/internal-helpers/src/remote.ts.
Where is matchHostname() defined?
matchHostname() is defined in packages/internal-helpers/src/remote.ts at line 54.
What calls matchHostname()?
matchHostname() is called by 2 function(s): isRemoteAllowed, matchPattern.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free