Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(pages): ignore expression delimiters within quotes (#6033)
Browse files Browse the repository at this point in the history
* fix(pages): ignore expression delimiters within quotes

* perf: use re

* test: add test that would have failed
  • Loading branch information
danielroe authored Jul 21, 2022
1 parent b4b9804 commit 8f7b9f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/nuxt/src/pages/macros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const starts = {
"'": "'"
}

const QUOTE_RE = /["']/

function extractObject (code: string) {
// Strip comments
code = code.replace(/^\s*\/\/.*$/gm, '')
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/basic/pages/no-auth.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup>
definePageMeta({
title: "l'equipe"
// middleware: 'inject-auth'
})
</script>
Expand Down

0 comments on commit 8f7b9f9

Please sign in to comment.