Skip to content

Commit 3024443

Browse files
committed
fix(ext/node): support ipv6 host in node:http
1 parent 28d94f4 commit 3024443

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ext/node/polyfills/http.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ import { methods as METHODS } from "node:_http_common";
9898
import { deprecate } from "node:util";
9999

100100
const { internalRidSymbol } = core;
101-
const { ArrayIsArray, StringPrototypeToLowerCase, SafeArrayIterator } =
102-
primordials;
101+
const {
102+
ArrayIsArray,
103+
StringPrototypeIncludes,
104+
StringPrototypeToLowerCase,
105+
SafeArrayIterator,
106+
} = primordials;
103107

104108
type Chunk = string | Buffer | Uint8Array;
105109

@@ -969,9 +973,9 @@ class ClientRequest extends OutgoingMessage {
969973
path = "/" + path;
970974
}
971975
const url = new URL(
972-
`${protocol}//${auth ? `${auth}@` : ""}${host}${
973-
port === 80 ? "" : `:${port}`
974-
}${path}`,
976+
`${protocol}//${auth ? `${auth}@` : ""}${
977+
StringPrototypeIncludes(host, ":") ? `[${host}]` : host
978+
}${port === 80 ? "" : `:${port}`}${path}`,
975979
);
976980
url.hash = hash;
977981
return url.href;

0 commit comments

Comments
 (0)