Skip to content

Commit 57276b7

Browse files
authored
fix: server and preview open fails to add slash before relative path (#11394)
1 parent 2059319 commit 57276b7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/vite/src/node/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export async function preview(
161161
openBrowser(
162162
path.startsWith('http')
163163
? path
164-
: `${protocol}://${hostname.name}:${serverPort}${path}`,
164+
: new URL(path, `${protocol}://${hostname.name}:${serverPort}`).href,
165165
true,
166166
logger,
167167
)

packages/vite/src/node/server/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ async function startServer(
679679
openBrowser(
680680
path.startsWith('http')
681681
? path
682-
: `${protocol}://${hostname.name}:${serverPort}${path}`,
682+
: new URL(path, `${protocol}://${hostname.name}:${serverPort}`).href,
683683
true,
684684
server.config.logger,
685685
)

0 commit comments

Comments
 (0)