mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
url: Make zero a valid port (#4963)
This commit is contained in:
parent
5a03e42117
commit
927a771fa4
2 changed files with 11 additions and 19 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue