From 74dde790ffcd982fa9824ed38b8ba5afccb8f609 Mon Sep 17 00:00:00 2001 From: ferdisap <100170686+ferdisap@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:32:26 +0700 Subject: [PATCH 1/3] Update client.ts@cleanUrl to accomodate blob protocol i would like to display view in browser using blob. But it is not 'hot update' because the using protocol 'blob'. It cause an TypeError: Failed to construct 'URL': Invalid URL at client.ts@cleanUrl. So thats why i change the code at client.ts@cleanUrl, line 114. --- packages/vite/src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 45c123213c5446..56c9a86915546d 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -111,7 +111,7 @@ function setupWebSocket( } function cleanUrl(pathname: string): string { - const url = new URL(pathname, location.toString()) + const url = new URL(pathname, location.protocol === 'blob:' ? location.pathname : location.toString()); url.searchParams.delete('direct') return url.pathname + url.search } From 5748ec67e04cae719e3a49df06e4a09ff9a1dd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Mar 2024 16:13:46 +0900 Subject: [PATCH 2/3] refactor: avoid using `location` --- packages/vite/src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 56c9a86915546d..509d1e2399e1c2 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -111,7 +111,7 @@ function setupWebSocket( } function cleanUrl(pathname: string): string { - const url = new URL(pathname, location.protocol === 'blob:' ? location.pathname : location.toString()); + const url = new URL(pathname, 'http://vitejs.dev'); url.searchParams.delete('direct') return url.pathname + url.search } From 1bd3e8a8fe7213207a7444480a0f923a40935d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Mar 2024 16:14:25 +0900 Subject: [PATCH 3/3] chore: format --- packages/vite/src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 509d1e2399e1c2..38b632cb945b57 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -111,7 +111,7 @@ function setupWebSocket( } function cleanUrl(pathname: string): string { - const url = new URL(pathname, 'http://vitejs.dev'); + const url = new URL(pathname, 'http://vitejs.dev') url.searchParams.delete('direct') return url.pathname + url.search }