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:
parent
f4b11db072
commit
ee4bfe1600
2 changed files with 7 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue