From 8831e4a4b9d5fc95b080869596c05793f2a3e601 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 10 Jun 2022 16:17:11 +0100 Subject: [PATCH] fix(vite): don't terminate with escaped delimiters (#5409) --- packages/vite/src/plugins/dynamic-base.ts | 2 +- test/basic.test.ts | 2 ++ test/fixtures/basic/pages/assets.vue | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/plugins/dynamic-base.ts b/packages/vite/src/plugins/dynamic-base.ts index a88d93e5c2..9a55d69458 100644 --- a/packages/vite/src/plugins/dynamic-base.ts +++ b/packages/vite/src/plugins/dynamic-base.ts @@ -89,7 +89,7 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"') // Dynamically compute string URLs featuring baseURL - const delimiterRE = /(? '`' + r.replace(/\/__NUXT_BASE__\//g, '${__publicAssetsURL()}').slice(1, -1) + '`') diff --git a/test/basic.test.ts b/test/basic.test.ts index 929d250163..ea4ce3a0ca 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -349,6 +349,8 @@ describe('dynamic paths', () => { [ "./logo.svg", "../public.svg", + "../public.svg", + "../public.svg", ] `) }) diff --git a/test/fixtures/basic/pages/assets.vue b/test/fixtures/basic/pages/assets.vue index 40648319ca..121d4fe46e 100644 --- a/test/fixtures/basic/pages/assets.vue +++ b/test/fixtures/basic/pages/assets.vue @@ -13,8 +13,14 @@ import logo from '~/assets/logo.svg'