Skip to content

Commit

Permalink
fix: port should be string
Browse files Browse the repository at this point in the history
reverts 325cb8b
  • Loading branch information
pi0 committed Feb 16, 2023
1 parent 9741e57 commit 75a280c
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: number;
port: string;
}

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 ? Number.parseInt(port) : undefined,
port,
};
}

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 75a280c

Please sign in to comment.