whatwg-url
Advanced tools
Comparing version 8.6.0 to 8.7.0
@@ -9,6 +9,6 @@ "use strict"; | ||
if (hex.length === 1) { | ||
hex = "0" + hex; | ||
hex = `0${hex}`; | ||
} | ||
return "%" + hex; | ||
return `%${hex}`; | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -58,7 +58,7 @@ "use strict"; | ||
get protocol() { | ||
return this._url.scheme + ":"; | ||
return `${this._url.scheme}:`; | ||
} | ||
set protocol(v) { | ||
usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); | ||
usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: "scheme start" }); | ||
} | ||
@@ -101,3 +101,3 @@ | ||
return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); | ||
return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`; | ||
} | ||
@@ -158,3 +158,3 @@ | ||
return "/" + this._url.path.join("/"); | ||
return `/${this._url.path.join("/")}`; | ||
} | ||
@@ -176,3 +176,3 @@ | ||
return "?" + this._url.query; | ||
return `?${this._url.query}`; | ||
} | ||
@@ -204,3 +204,3 @@ | ||
return "#" + this._url.fragment; | ||
return `#${this._url.fragment}`; | ||
} | ||
@@ -207,0 +207,0 @@ |
@@ -53,7 +53,7 @@ "use strict"; | ||
function containsForbiddenHostCodePoint(string) { | ||
return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/) !== -1; | ||
return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u) !== -1; | ||
} | ||
function containsForbiddenHostCodePointExcludingPercent(string) { | ||
return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/) !== -1; | ||
return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u) !== -1; | ||
} | ||
@@ -92,8 +92,8 @@ | ||
let regex = /[^0-7]/; | ||
let regex = /[^0-7]/u; | ||
if (R === 10) { | ||
regex = /[^0-9]/; | ||
regex = /[^0-9]/u; | ||
} | ||
if (R === 16) { | ||
regex = /[^0-9A-Fa-f]/; | ||
regex = /[^0-9A-Fa-f]/u; | ||
} | ||
@@ -138,3 +138,3 @@ | ||
} | ||
if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { | ||
if (numbers[numbers.length - 1] >= 256 ** (5 - numbers.length)) { | ||
return failure; | ||
@@ -147,3 +147,3 @@ } | ||
for (const n of numbers) { | ||
ipv4 += n * Math.pow(256, 3 - counter); | ||
ipv4 += n * 256 ** (3 - counter); | ||
++counter; | ||
@@ -162,3 +162,3 @@ } | ||
if (i !== 4) { | ||
output = "." + output; | ||
output = `.${output}`; | ||
} | ||
@@ -406,3 +406,3 @@ n = Math.floor(n / 256); | ||
if (host instanceof Array) { | ||
return "[" + serializeIPv6(host) + "]"; | ||
return `[${serializeIPv6(host)}]`; | ||
} | ||
@@ -428,7 +428,7 @@ | ||
function trimControlChars(url) { | ||
return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); | ||
return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/ug, ""); | ||
} | ||
function trimTabAndNewline(url) { | ||
return url.replace(/\u0009|\u000A|\u000D/g, ""); | ||
return url.replace(/\u0009|\u000A|\u000D/ug, ""); | ||
} | ||
@@ -457,3 +457,3 @@ | ||
function isNormalizedWindowsDriveLetter(string) { | ||
return /^[A-Za-z]:$/.test(string); | ||
return /^[A-Za-z]:$/u.test(string); | ||
} | ||
@@ -512,3 +512,3 @@ | ||
// exec state machine | ||
const ret = this["parse " + this.state](c, cStr); | ||
const ret = this[`parse ${this.state}`](c, cStr); | ||
if (!ret) { | ||
@@ -720,3 +720,3 @@ break; // terminate algorithm | ||
if (this.atFlag) { | ||
this.buffer = "%40" + this.buffer; | ||
this.buffer = `%40${this.buffer}`; | ||
} | ||
@@ -824,3 +824,3 @@ this.atFlag = true; | ||
const port = parseInt(this.buffer); | ||
if (port > Math.pow(2, 16) - 1) { | ||
if (port > 2 ** 16 - 1) { | ||
this.parseError = true; | ||
@@ -971,2 +971,4 @@ return failure; | ||
} | ||
} else if (this.stateOverride && this.url.host === null) { | ||
this.url.path.push(""); | ||
} | ||
@@ -994,3 +996,3 @@ | ||
if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { | ||
this.buffer = this.buffer[0] + ":"; | ||
this.buffer = `${this.buffer[0]}:`; | ||
} | ||
@@ -1096,3 +1098,3 @@ this.url.path.push(this.buffer); | ||
function serializeURL(url, excludeFragment) { | ||
let output = url.scheme + ":"; | ||
let output = `${url.scheme}:`; | ||
if (url.host !== null) { | ||
@@ -1104,3 +1106,3 @@ output += "//"; | ||
if (url.password !== "") { | ||
output += ":" + url.password; | ||
output += `:${url.password}`; | ||
} | ||
@@ -1113,3 +1115,3 @@ output += "@"; | ||
if (url.port !== null) { | ||
output += ":" + url.port; | ||
output += `:${url.port}`; | ||
} | ||
@@ -1125,3 +1127,3 @@ } | ||
for (const segment of url.path) { | ||
output += "/" + segment; | ||
output += `/${segment}`; | ||
} | ||
@@ -1131,7 +1133,7 @@ } | ||
if (url.query !== null) { | ||
output += "?" + url.query; | ||
output += `?${url.query}`; | ||
} | ||
if (!excludeFragment && url.fragment !== null) { | ||
output += "#" + url.fragment; | ||
output += `#${url.fragment}`; | ||
} | ||
@@ -1143,7 +1145,7 @@ | ||
function serializeOrigin(tuple) { | ||
let result = tuple.scheme + "://"; | ||
let result = `${tuple.scheme}://`; | ||
result += serializeHost(tuple.host); | ||
if (tuple.port !== null) { | ||
result += ":" + tuple.port; | ||
result += `:${tuple.port}`; | ||
} | ||
@@ -1150,0 +1152,0 @@ |
@@ -14,4 +14,3 @@ "use strict"; | ||
let name; | ||
let value; | ||
let name, value; | ||
const indexOfEqual = bytes.indexOf(61); | ||
@@ -18,0 +17,0 @@ |
{ | ||
"name": "whatwg-url", | ||
"version": "8.6.0", | ||
"version": "8.7.0", | ||
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery", | ||
@@ -20,8 +20,9 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@domenic/eslint-config": "^1.2.0", | ||
"browserify": "^17.0.0", | ||
"domexception": "^2.0.1", | ||
"eslint": "^7.28.0", | ||
"eslint": "^7.29.0", | ||
"glob": "^7.1.7", | ||
"got": "^11.8.2", | ||
"jest": "^27.0.4", | ||
"jest": "^27.0.5", | ||
"recast": "^0.20.4", | ||
@@ -28,0 +29,0 @@ "webidl2js": "^16.2.0" |
@@ -7,3 +7,3 @@ # whatwg-url | ||
whatwg-url is currently up to date with the URL spec up to commit [6d4669a](https://github.com/whatwg/url/commit/6d4669a9a8cc90582bdb1e3cdb758e45242812b0). | ||
whatwg-url is currently up to date with the URL spec up to commit [0672f2e](https://github.com/whatwg/url/commit/0672f2e2ef43aca18b59d90abb6dac21712399bb). | ||
@@ -10,0 +10,0 @@ For `file:` URLs, whose [origin is left unspecified](https://url.spec.whatwg.org/#concept-url-origin), whatwg-url chooses to use a new opaque origin (which serializes to `"null"`). |
90738
2474
9