fix(pages): ignore expression delimiters within quotes (#6033)

* fix(pages): ignore expression delimiters within quotes

* perf: use re

* test: add test that would have failed
This commit is contained in:
Daniel Roe 2022-07-21 14:49:48 +01:00 committed by GitHub
parent b4b98041f0
commit 8f7b9f904e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -98,6 +98,8 @@ const starts = {
"'": "'"
}
const QUOTE_RE = /["']/
function extractObject (code: string) {
// Strip comments
code = code.replace(/^\s*\/\/.*$/gm, '')
@ -107,7 +109,7 @@ function extractObject (code: string) {
do {
if (stack[0] === code[0] && result.slice(-1) !== '\\') {
stack.shift()
} else if (code[0] in starts) {
} else if (code[0] in starts && !QUOTE_RE.test(stack[0])) {
stack.unshift(starts[code[0]])
}
result += code[0]

View File

@ -1,5 +1,6 @@
<script setup>
definePageMeta({
title: "l'equipe"
// middleware: 'inject-auth'
})
</script>