mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): use original escapes/quotes in page re-exports (#23191)
This commit is contained in:
parent
16e40f899e
commit
e729406805
@ -65,8 +65,10 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
|||||||
// [vite] Re-export any script imports
|
// [vite] Re-export any script imports
|
||||||
const scriptImport = imports.find(i => parseMacroQuery(i.specifier).type === 'script')
|
const scriptImport = imports.find(i => parseMacroQuery(i.specifier).type === 'script')
|
||||||
if (scriptImport) {
|
if (scriptImport) {
|
||||||
const specifier = rewriteQuery(scriptImport.specifier)
|
const reorderedQuery = rewriteQuery(scriptImport.specifier)
|
||||||
s.overwrite(0, code.length, `export { default } from ${JSON.stringify(specifier)}`)
|
// Avoid using JSON.stringify which can add extra escapes to paths with non-ASCII characters
|
||||||
|
const quotedSpecifier = getQuotedSpecifier(scriptImport.code)?.replace(scriptImport.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery)
|
||||||
|
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`)
|
||||||
return result()
|
return result()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +79,10 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const specifier = rewriteQuery(match.specifier)
|
const reorderedQuery = rewriteQuery(match.specifier)
|
||||||
s.overwrite(0, code.length, `export { default } from ${JSON.stringify(specifier)}`)
|
// Avoid using JSON.stringify which can add extra escapes to paths with non-ASCII characters
|
||||||
|
const quotedSpecifier = getQuotedSpecifier(match.code)?.replace(match.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery)
|
||||||
|
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`)
|
||||||
return result()
|
return result()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,3 +187,7 @@ function parseMacroQuery (id: string) {
|
|||||||
}
|
}
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQuotedSpecifier (id: string) {
|
||||||
|
return id.match(/(["']).*\1/)?.[0]
|
||||||
|
}
|
||||||
|
8
test/fixtures/basic/pages/non-ascii/ç.vue
vendored
Normal file
8
test/fixtures/basic/pages/non-ascii/ç.vue
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- -->
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue
Block a user