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

View File

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