From 874c44b072d55fe42a29d366dbe1c71ca3a94db4 Mon Sep 17 00:00:00 2001 From: Sheng Chou <38355699+chousheng@users.noreply.github.com> Date: Thu, 11 May 2023 21:42:33 -0700 Subject: [PATCH] fix: replace `::` with `localhost` before openBrowser() (#4856) --- lib/Server.js | 4 +++- test/server/open-option.test.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 0c093b2415..79e6fc7910 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -2955,7 +2955,9 @@ class Server { if (/** @type {NormalizedOpen[]} */ (this.options.open).length > 0) { const openTarget = prettyPrintURL( - !this.options.host || this.options.host === "0.0.0.0" + !this.options.host || + this.options.host === "0.0.0.0" || + this.options.host === "::" ? "localhost" : this.options.host ); diff --git a/test/server/open-option.test.js b/test/server/open-option.test.js index 5a624b00bb..13c4131d3e 100644 --- a/test/server/open-option.test.js +++ b/test/server/open-option.test.js @@ -134,7 +134,7 @@ describe('"open" option', () => { await server.start(); await server.stop(); - expect(open).toHaveBeenCalledWith(`http://[${host}]:${port}/`, { + expect(open).toHaveBeenCalledWith(`http://localhost:${port}/`, { wait: false, }); });