diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 4c940aa109b00a..6d758e04cd807c 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -40,7 +40,6 @@ import { joinUrlSegments, moduleListContains, normalizePath, - partialEncodeURIPath, prettifyUrl, removeImportQuery, removeTimestampQuery, @@ -594,9 +593,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { rewriteDone = true } if (!rewriteDone) { - const rewrittenUrl = JSON.stringify( - ssr ? url : partialEncodeURIPath(url), - ) + const rewrittenUrl = JSON.stringify(url) const s = isDynamicImport ? start : start - 1 const e = isDynamicImport ? end : end + 1 str().overwrite(s, e, rewrittenUrl, { diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index 6fb337a9484bb6..fb00f0ac2041f8 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -369,11 +369,11 @@ test('?url import on css', async () => { describe('unicode url', () => { test('from js import', async () => { - const src = readFile('テスト-測試-white space%.js') + const src = readFile('テスト-測試-white space.js') expect(await page.textContent('.unicode-url')).toMatch( isBuild ? `data:text/javascript;base64,${Buffer.from(src).toString('base64')}` - : encodeURI(`/foo/bar/テスト-測試-white space%.js`), + : encodeURI(`/foo/bar/テスト-測試-white space.js`), ) }) }) diff --git a/playground/assets/asset/percent%.png b/playground/assets/asset/percent%.png new file mode 100644 index 00000000000000..628bbd479129c0 Binary files /dev/null and b/playground/assets/asset/percent%.png differ diff --git a/playground/assets/index.html b/playground/assets/index.html index 80fbf14be8bc59..3180f2c966c00c 100644 --- a/playground/assets/index.html +++ b/playground/assets/index.html @@ -135,7 +135,7 @@
-
+
+
+
+