BuildUrlResolver Class — astro Architecture
Architecture documentation for the BuildUrlResolver class in build-url-resolver.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD d01a7ebc_4580_9594_03a5_09c288058f31["BuildUrlResolver"] ec6f0fc1_13a9_70de_0a11_49e48eea41af["build-url-resolver.ts"] d01a7ebc_4580_9594_03a5_09c288058f31 -->|defined in| ec6f0fc1_13a9_70de_0a11_49e48eea41af 299e934e_091e_ac6f_ed0f_8cef600979a4["constructor()"] d01a7ebc_4580_9594_03a5_09c288058f31 -->|method| 299e934e_091e_ac6f_ed0f_8cef600979a4 322ea36f_8079_fb27_1ebe_e5333b36af04["resolve()"] d01a7ebc_4580_9594_03a5_09c288058f31 -->|method| 322ea36f_8079_fb27_1ebe_e5333b36af04 b53f381b_89c9_fce2_6cb9_ba93451a97c2["cspResources()"] d01a7ebc_4580_9594_03a5_09c288058f31 -->|method| b53f381b_89c9_fce2_6cb9_ba93451a97c2
Relationship Graph
Source Code
packages/astro/src/assets/fonts/infra/build-url-resolver.ts lines 7–52
export class BuildUrlResolver implements UrlResolver {
readonly #resources = new Set<string>();
readonly #base: string;
readonly #assetsPrefix: AssetsPrefix;
readonly #searchParams: URLSearchParams;
constructor({
base,
assetsPrefix,
searchParams,
}: {
base: string;
assetsPrefix: AssetsPrefix;
searchParams: URLSearchParams;
}) {
this.#base = base;
this.#assetsPrefix = assetsPrefix;
this.#searchParams = searchParams;
}
resolve(id: string): string {
const prefix = this.#assetsPrefix
? getAssetsPrefix(fileExtension(id), this.#assetsPrefix)
: undefined;
let urlPath: string;
if (prefix) {
this.#resources.add(prefix);
urlPath = joinPaths(prefix, this.#base, id);
} else {
this.#resources.add("'self'");
urlPath = prependForwardSlash(joinPaths(this.#base, id));
}
// Create URL object and append searchParams if available (for adapter-level tracking like skew protection)
const url = createPlaceholderURL(urlPath);
this.#searchParams.forEach((value, key) => {
url.searchParams.set(key, value);
});
return stringifyPlaceholderURL(url);
}
get cspResources(): Array<string> {
return Array.from(this.#resources);
}
}
Domain
Source
Frequently Asked Questions
What is the BuildUrlResolver class?
BuildUrlResolver is a class in the astro codebase, defined in packages/astro/src/assets/fonts/infra/build-url-resolver.ts.
Where is BuildUrlResolver defined?
BuildUrlResolver is defined in packages/astro/src/assets/fonts/infra/build-url-resolver.ts at line 7.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free