mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 15:10:58 +00:00
fix(vite): use single regex to reduce risk of collisions (#4442)
This commit is contained in:
parent
4fe97389b6
commit
4c6c027014
@ -88,11 +88,9 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
|
|||||||
s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"')
|
s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"')
|
||||||
|
|
||||||
// Dynamically compute string URLs featuring baseURL
|
// Dynamically compute string URLs featuring baseURL
|
||||||
for (const delimiter of ['`', "'", '"']) {
|
const delimiterRE = /(?<!(const base = |from *))(`([^`]*)\/__NUXT_BASE__\/([^`]*)`|'([^']*)\/__NUXT_BASE__\/([^']*)'|"([^"]*)\/__NUXT_BASE__\/([^"]*)")/g
|
||||||
const delimiterRE = new RegExp(`(?<!(const base = |from *))${delimiter}([^${delimiter}]*)\\/__NUXT_BASE__\\/([^${delimiter}]*)${delimiter}`, 'g')
|
/* eslint-disable-next-line no-template-curly-in-string */
|
||||||
/* eslint-disable-next-line no-template-curly-in-string */
|
s.replace(delimiterRE, r => '`' + r.replace(/\/__NUXT_BASE__\//g, '${__publicAssetsURL()}').slice(1, -1) + '`')
|
||||||
s.replace(delimiterRE, r => '`' + r.replace(/\/__NUXT_BASE__\//g, '${__publicAssetsURL()}').slice(1, -1) + '`')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s.hasChanged()) {
|
if (s.hasChanged()) {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user