Skip to content

Commit c186152

Browse files
committed
chore: speed up regex
#2363
1 parent cc25dbd commit c186152

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/svelte2tsx/src/utils/htmlxparser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ function parseAttributes(str: string, start: number) {
3232

3333
// Regex ensures that attributes with > characters in them still result in the content being matched correctly
3434
const scriptRegex =
35-
/(<!--[^]*?-->)|(<script((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)>)([\S\s]*?)<\/script>/g;
35+
/(<!--[^]*?-->)|(<script((?:\s+[^=>'"\/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/\s]+)*\s*)>)([\S\s]*?)<\/script>/g;
3636
const styleRegex =
37-
/(<!--[^]*?-->)|(<style((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)>)([\S\s]*?)<\/style>/g;
37+
/(<!--[^]*?-->)|(<style((?:\s+[^=>'"\/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/\s]+)*\s*)>)([\S\s]*?)<\/style>/g;
3838

3939
function extractTag(htmlx: string, tag: 'script' | 'style') {
4040
const exp = tag === 'script' ? scriptRegex : styleRegex;

0 commit comments

Comments
 (0)