Skip to content

Commit

Permalink
fix port type
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 16, 2023
1 parent ce1aaf4 commit 325cb8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ParsedAuth {

export interface ParsedHost {
hostname: string;
port: string;
port: number;
}

export function parseURL(input = "", defaultProto?: string): ParsedURL {
Expand Down Expand Up @@ -68,7 +68,7 @@ export function parseHost(input = ""): ParsedHost {
const [hostname, port] = (input.match(/([^/:]*):?(\d+)?/) || []).splice(1);
return {
hostname: decode(hostname),
port,
port: port ? Number.parseInt(port) : undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("parseURL", () => {

describe("parseHost", () => {
const tests = [
{ input: "localhost:3000", out: { hostname: "localhost", port: "3000" } },
{ input: "localhost:3000", out: { hostname: "localhost", port: 3000 } },
{ input: "google.com", out: { hostname: "google.com", port: undefined } },
];

Expand Down

0 comments on commit 325cb8b

Please sign in to comment.