Skip to content

Commit

Permalink
fix: port
Browse files Browse the repository at this point in the history
Update URL.mts
Update URL.mjs
  • Loading branch information
VirgilClyne committed Nov 28, 2024
1 parent d2bebb9 commit e9585f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 10 additions & 3 deletions URL.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ export class URL {
return port;
}
set port(value) {
const port = Number.parseInt(value, 10);
if (port >= 0 && port < 65535)
this.#url.port = port;
switch (value) {
case "":
this.#url.port = Number.NaN;
break;
default: {
const port = Number.parseInt(value, 10);
if (port >= 0 && port < 65535)
this.#url.port = port;
}
}
}
get protocol() {
return `${this.#url.protocol}:`;
Expand Down
11 changes: 9 additions & 2 deletions URL.mts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,15 @@ export class URL {
return port;
}
set port(value: string) {
const port = Number.parseInt(value, 10);
if (port >= 0 && port < 65535) this.#url.port = port;
switch (value) {
case "":
this.#url.port = Number.NaN;
break;
default: {
const port = Number.parseInt(value, 10);
if (port >= 0 && port < 65535) this.#url.port = port;
}
}
}
get protocol() {
return `${this.#url.protocol}:`;
Expand Down

0 comments on commit e9585f0

Please sign in to comment.