From 927a771fa438ed9833a82fd87521bef50f4b4adc Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Tue, 28 Apr 2020 16:40:17 +0200 Subject: url: Make zero a valid port (#4963) --- cli/js/web/url.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cli/js/web/url.ts') diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts index 77285e456..6a8dc6627 100644 --- a/cli/js/web/url.ts +++ b/cli/js/web/url.ts @@ -193,10 +193,10 @@ export class URLImpl implements URL { // https://url.spec.whatwg.org/#port-state if (value === "") return value; - const port = parseInt(value, 10); - - if (!Number.isNaN(port) && port > 0 && port <= MAX_PORT) + const port = Number(value); + if (Number.isInteger(port) && port >= 0 && port <= MAX_PORT) { return port.toString(); + } return undefined; }; -- cgit v1.2.3