the editable site (validation-lab)
This commit is contained in:
commit
3ac81d5a52
13454 files changed
+2227005
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
import { joinPaths, prependForwardSlash } from "../../../core/path.js";
|
||||
import { createPlaceholderURL, stringifyPlaceholderURL } from "../../utils/url.js";
|
||||
class DevUrlResolver {
|
||||
#resolved = false;
|
||||
#base;
|
||||
#searchParams;
|
||||
constructor({
|
||||
base,
|
||||
searchParams
|
||||
}) {
|
||||
this.#base = base;
|
||||
this.#searchParams = searchParams;
|
||||
}
|
||||
resolve(id) {
|
||||
this.#resolved ||= true;
|
||||
const urlPath = prependForwardSlash(joinPaths(this.#base, id));
|
||||
const url = createPlaceholderURL(urlPath);
|
||||
this.#searchParams.forEach((value, key) => {
|
||||
url.searchParams.set(key, value);
|
||||
});
|
||||
return stringifyPlaceholderURL(url);
|
||||
}
|
||||
get cspResources() {
|
||||
return this.#resolved ? ["'self'"] : [];
|
||||
}
|
||||
}
|
||||
export {
|
||||
DevUrlResolver
|
||||
};
|
||||
Reference in new issue
Block a user