-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
When specifying cacheBustingQueryParam
, the private cacheBusting
is invoked, unintentionally prefixing the resulting string with /
. This disrupts relative URLs, causing incorrect path resolution.
favicons/src/platforms/base.ts
Line 101 in a4e4367
protected cacheBusting(path: string): string { |
const url = new URL(path, "https://cache.busting");
url.searchParams.set(paramParts[0], paramParts.slice(1).join("="));
return url.origin === "https://cache.busting"
? url.pathname + url.search
: url.toString();
You could potentially add something like:
protected cacheBusting(path: string): string {
if (typeof this.options.cacheBustingQueryParam !== "string") {
return path;
}
const paramParts = this.options.cacheBustingQueryParam.split("=");
if (paramParts.length === 1) {
return path;
}
const url = new URL(path, "https://cache.busting");
url.searchParams.set(paramParts[0], paramParts.slice(1).join("="));
if (url.origin !== "https://cache.busting") {
return url.toString();
}
const resolvedPath = url.pathname + url.search;
// Preserve relative paths
if (!path.startsWith("/") && resolvedPath.startsWith("/")) {
return resolvedPath.substring(1);
}
return resolvedPath;
}
Metadata
Metadata
Assignees
Labels
No labels