fix janky base stuff

This commit is contained in:
velzie 2024-09-03 10:23:17 -04:00
parent 09f4863e86
commit d3a86ab133
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F

View file

@ -111,23 +111,19 @@ export class ScramjetClient {
);
}
let baseurl: URL;
if (iswindow) {
// setup base url
// base url can only be updated at document load time and it will affect all urls resolved by encodeurl/rewriteurl
const base = this.global.document.querySelector("base");
if (base) {
baseurl = new URL(decodeUrl(base.href));
}
}
const client = this;
this.meta = {
get origin() {
return client.url;
},
get base() {
return baseurl || client.url;
if (iswindow) {
const base = client.global.document.querySelector("base");
if (base) {
return new URL(base.getAttribute(`href`), client.url.origin);
}
}
return client.url;
},
};