0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(ext/node): hostname is valid IPv4 addr (#23243)

Fixes `docusaurus serve`
This commit is contained in:
Divy Srivastava 2024-04-05 17:42:26 +05:30 committed by GitHub
parent f4b11db072
commit ee4bfe1600
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -1653,7 +1653,10 @@ export class ServerImpl extends EventEmitter {
// TODO(bnoordhuis) Node prefers [::] when host is omitted,
// we on the other hand default to 0.0.0.0.
const hostname = options.host ?? "0.0.0.0";
let hostname = options.host ?? "0.0.0.0";
if (hostname == "localhost") {
hostname = "127.0.0.1";
}
this.#addr = {
hostname,
port,

View file

@ -27,7 +27,9 @@ Deno.test("[node/http listen]", async () => {
const { promise, resolve } = Promise.withResolvers<void>();
const server = http.createServer();
server.listen(() => {
server.listen(42453, "localhost", () => {
// @ts-ignore address() is not a string
assertEquals(server.address()!.address, "127.0.0.1");
server.close();
});
server.on("close", () => {