whatwg-url
Advanced tools
Comparing version 9.0.0 to 9.1.0
@@ -76,2 +76,6 @@ "use strict"; | ||
function parseIPv4Number(input) { | ||
if (input === "") { | ||
return failure; | ||
} | ||
let R = 10; | ||
@@ -115,3 +119,3 @@ | ||
if (parts.length > 4) { | ||
return input; | ||
return failure; | ||
} | ||
@@ -121,8 +125,5 @@ | ||
for (const part of parts) { | ||
if (part === "") { | ||
return input; | ||
} | ||
const n = parseIPv4Number(part); | ||
if (n === failure) { | ||
return input; | ||
return failure; | ||
} | ||
@@ -349,5 +350,4 @@ | ||
const ipv4Host = parseIPv4(asciiDomain); | ||
if (typeof ipv4Host === "number" || ipv4Host === failure) { | ||
return ipv4Host; | ||
if (endsInANumber(asciiDomain)) { | ||
return parseIPv4(asciiDomain); | ||
} | ||
@@ -358,2 +358,23 @@ | ||
function endsInANumber(input) { | ||
const parts = input.split("."); | ||
if (parts[parts.length - 1] === "") { | ||
if (parts.length === 1) { | ||
return false; | ||
} | ||
parts.pop(); | ||
} | ||
const last = parts[parts.length - 1]; | ||
if (parseIPv4Number(last) !== failure) { | ||
return true; | ||
} | ||
if (/^[0-9]+$/u.test(last)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function parseOpaqueHost(input) { | ||
@@ -360,0 +381,0 @@ if (containsForbiddenHostCodePointExcludingPercent(input)) { |
{ | ||
"name": "whatwg-url", | ||
"version": "9.0.0", | ||
"version": "9.1.0", | ||
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,3 +7,3 @@ # whatwg-url | ||
whatwg-url is currently up to date with the URL spec up to commit [0672f2e](https://github.com/whatwg/url/commit/0672f2e2ef43aca18b59d90abb6dac21712399bb). | ||
whatwg-url is currently up to date with the URL spec up to commit [ab0e820](https://github.com/whatwg/url/commit/ab0e820b0b559610b30c731b7f2c1a8094181680). | ||
@@ -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"`). |
90727
2485