astro
Version:
Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
41 lines (40 loc) • 1.3 kB
JavaScript
import { fileExtension, joinPaths, prependForwardSlash } from "../../../core/path.js";
import { getAssetsPrefix } from "../../utils/getAssetsPrefix.js";
import { createPlaceholderURL, stringifyPlaceholderURL } from "../../utils/url.js";
export class BuildUrlResolver {
constructor({ base, assetsPrefix, searchParams }) {
this.
this.
this.
}
resolve(id) {
const prefix = this.
let urlPath;
if (prefix) {
this.
urlPath = joinPaths(prefix, this.
} else {
this.
urlPath = prependForwardSlash(joinPaths(this.
}
// Create URL object and append searchParams if available (for adapter-level tracking like skew protection)
const url = createPlaceholderURL(urlPath);
this.
url.searchParams.set(key, value);
});
const result = stringifyPlaceholderURL(url);
this.
return result;
}
get cspResources() {
return Array.from(this.
}
get urls() {
return Array.from(this.
}
}