From 75a280c9e0d2bdfce597c36a64ea9ca5de7872f0 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 16 Feb 2023 18:51:31 +0100 Subject: [PATCH] fix: port should be string reverts https://github.com/unjs/ufo/pull/120/commits/325cb8b88c213dc00a13b6fb1fa3902a4bfdf190 --- src/parse.ts | 4 ++-- test/parse.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parse.ts b/src/parse.ts index 6459d538..2e85f9ce 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -16,7 +16,7 @@ export interface ParsedAuth { export interface ParsedHost { hostname: string; - port: number; + port: string; } export function parseURL(input = "", defaultProto?: string): ParsedURL { @@ -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, }; } diff --git a/test/parse.test.ts b/test/parse.test.ts index a6147b30..8ee7fedb 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -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 } }, ];