Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
set protocol(v) {
reinitializeURL(this);
if (this.url === null) {
return;
}
whatwgURL.basicURLParse(v + ":", { url: this.url, stateOverride: "scheme start" });
updateHref(this);
}
set host(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.cannotBeABaseURL) {
return;
}
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "host" });
this._locationObjectSetterNavigate(copyURL);
}
set search(v) {
const copyURL = Object.assign({}, this._url);
if (v === "") {
copyURL.query = null;
} else {
const input = v[0] === "?" ? v.substring(1) : v;
copyURL.query = "";
whatwgURL.basicURLParse(input, {
url: copyURL,
stateOverride: "query",
encodingOverride: this._relevantDocument.charset
});
}
this._locationObjectSetterNavigate(copyURL);
}
set port(v) {
reinitializeURL(this);
const { url } = this;
if (url === null || url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file") {
return;
}
if (v === "") {
url.port = null;
} else {
whatwgURL.basicURLParse(v, { url, stateOverride: "port" });
}
updateHref(this);
}
set protocol(v) {
const copyURL = Object.assign({}, this._url);
const possibleFailure = whatwgURL.basicURLParse(v + ":", { url: copyURL, stateOverride: "scheme start" });
if (possibleFailure === null) {
throw new TypeError(`Could not parse the URL after setting the procol to "${v}"`);
}
if (copyURL.scheme !== "http" && copyURL.scheme !== "https") {
return;
}
this._locationObjectSetterNavigate(copyURL);
}
set pathname(v) {
reinitializeURL(this);
const { url } = this;
if (url === null || url.cannotBeABaseURL) {
return;
}
url.path = [];
whatwgURL.basicURLParse(v, { url, stateOverride: "path start" });
updateHref(this);
}
set port(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.host === null || copyURL.cannotBeABaseURL || copyURL.scheme === "file") {
return;
}
whatwgURL.basicURLParse(v, { url: copyURL, stateOverride: "port" });
this._locationObjectSetterNavigate(copyURL);
}
set pathname(v) {
reinitializeURL(this);
const { url } = this;
if (url === null || url.cannotBeABaseURL) {
return;
}
url.path = [];
whatwgURL.basicURLParse(v, { url, stateOverride: "path start" });
updateHref(this);
}
set hash(v) {
reinitializeURL(this);
const { url } = this;
if (url === null) {
return;
}
if (v === "") {
url.fragment = null;
} else {
const input = v[0] === "#" ? v.substring(1) : v;
url.fragment = "";
whatwgURL.basicURLParse(input, { url, stateOverride: "fragment" });
}
updateHref(this);
}
};
set hash(v) {
const copyURL = Object.assign({}, this._url);
if (copyURL.scheme === "javascript") {
return;
}
if (v === "") {
copyURL.fragment = null;
} else {
const input = v[0] === "#" ? v.substring(1) : v;
copyURL.fragment = "";
whatwgURL.basicURLParse(input, { url: copyURL, stateOverride: "fragment" });
}
this._locationObjectSetterNavigate(copyURL);
}