diff options
author | 2024-08-07 16:01:23 +0800 | |
---|---|---|
committer | 2024-08-07 16:01:23 +0800 | |
commit | ea82b03cd6d40c6bd541046f2f9aedfed058ff4f (patch) | |
tree | 620fbe169215cba926d7f6376a8b75cb7c12c8e3 /packages/integrations/vue | |
parent | 74a093056df99b2714ecc30fc2c36e88778dd9ce (diff) | |
download | astro-ea82b03cd6d40c6bd541046f2f9aedfed058ff4f.tar.gz astro-ea82b03cd6d40c6bd541046f2f9aedfed058ff4f.tar.zst astro-ea82b03cd6d40c6bd541046f2f9aedfed058ff4f.zip |
Improve regex performance (#11635)
Diffstat (limited to 'packages/integrations/vue')
-rw-r--r-- | packages/integrations/vue/src/editor.cts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/packages/integrations/vue/src/editor.cts b/packages/integrations/vue/src/editor.cts index d4f10aab6..64b34b45b 100644 --- a/packages/integrations/vue/src/editor.cts +++ b/packages/integrations/vue/src/editor.cts @@ -24,7 +24,7 @@ export function toTSX(code: string, className: string): string { if (scriptSetup) { const codeWithoutComments = scriptSetup.content.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, ''); - const definePropsType = codeWithoutComments.match(/defineProps<([\s\S]+?)>\s?\(\)/); + const definePropsType = /defineProps<([\s\S]+?)>\s?\(\)/.exec(codeWithoutComments); const propsGeneric = scriptSetup.attrs.generic; const propsGenericType = propsGeneric ? `<${propsGeneric}>` : ''; @@ -41,7 +41,7 @@ export function toTSX(code: string, className: string): string { // TODO. Find a way to support generics when using defineProps without passing explicit types. // Right now something like this `defineProps({ prop: { type: Array as PropType<T[]> } })` // won't be correctly typed in Astro. - const defineProps = codeWithoutComments.match(/defineProps\([\s\S]+?\)/); + const defineProps = /defineProps\([\s\S]+?\)/.exec(codeWithoutComments); if (defineProps) { result = ` import { defineProps } from 'vue'; |