url: Make zero a valid port (#4963)

This commit is contained in:
Marcos Casagrande 2020-04-28 16:40:17 +02:00 committed by GitHub
parent 5a03e42117
commit 927a771fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 19 deletions

View file

@ -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;
};