Home / File/ build-url-resolver.ts — astro Source File

build-url-resolver.ts — astro Source File

Architecture documentation for build-url-resolver.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  ec6f0fc1_13a9_70de_0a11_49e48eea41af["build-url-resolver.ts"]
  7e4494c0_5563_4329_1bff_a84be66e1bc2["../core/path.js"]
  ec6f0fc1_13a9_70de_0a11_49e48eea41af --> 7e4494c0_5563_4329_1bff_a84be66e1bc2
  baa53824_73a3_1e03_2043_4d0c058ecca5["../types/public/index.js"]
  ec6f0fc1_13a9_70de_0a11_49e48eea41af --> baa53824_73a3_1e03_2043_4d0c058ecca5
  617c63d5_1302_acd7_3e75_06534fb7e782["../../assets/utils/getAssetsPrefix.js"]
  ec6f0fc1_13a9_70de_0a11_49e48eea41af --> 617c63d5_1302_acd7_3e75_06534fb7e782
  80b76311_6bb4_2889_b892_492680843683["./utils/url.js"]
  ec6f0fc1_13a9_70de_0a11_49e48eea41af --> 80b76311_6bb4_2889_b892_492680843683
  e92fda44_4a5d_b83b_1a45_958cdae6c91b["./definitions.js"]
  ec6f0fc1_13a9_70de_0a11_49e48eea41af --> e92fda44_4a5d_b83b_1a45_958cdae6c91b
  style ec6f0fc1_13a9_70de_0a11_49e48eea41af fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { fileExtension, joinPaths, prependForwardSlash } from '../../../core/path.js';
import type { AssetsPrefix } from '../../../types/public/index.js';
import { getAssetsPrefix } from '../../utils/getAssetsPrefix.js';
import { createPlaceholderURL, stringifyPlaceholderURL } from '../../utils/url.js';
import type { UrlResolver } from '../definitions.js';

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

Subdomains

Dependencies

  • ../../assets/utils/getAssetsPrefix.js
  • ../core/path.js
  • ../types/public/index.js
  • ./definitions.js
  • ./utils/url.js

Frequently Asked Questions

What does build-url-resolver.ts do?
build-url-resolver.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What does build-url-resolver.ts depend on?
build-url-resolver.ts imports 5 module(s): ../../assets/utils/getAssetsPrefix.js, ../core/path.js, ../types/public/index.js, ./definitions.js, ./utils/url.js.
Where is build-url-resolver.ts in the architecture?
build-url-resolver.ts is located at packages/astro/src/assets/fonts/infra/build-url-resolver.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/assets/fonts/infra).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free