From 0e48e774dc938a21ae5cfd1c97763c9a09a7b329 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 19 Apr 2023 22:43:05 +0200 Subject: [PATCH 1/2] ensure that last `]` doesn't stop the match Given this input: ```html
``` Then we would expect the match to be this: ``` [width:_calc(theme(spacing[5])_+_theme(spacing[5]))] ``` However, with the `?`, then it would stop and result in: ``` [width:_calc(theme(spacing[5])_+_theme(spacing[5] ``` Which makes it incomplete because the `))]` are missing at the end. --- src/lib/defaultExtractor.js | 2 +- tests/default-extractor.test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/defaultExtractor.js b/src/lib/defaultExtractor.js index cf3218736272..6382ca7cf3dc 100644 --- a/src/lib/defaultExtractor.js +++ b/src/lib/defaultExtractor.js @@ -35,7 +35,7 @@ function* buildRegExps(context) { // This is a targeted fix to continue to allow theme() // with square brackets to work in arbitrary properties // while fixing a problem with the regex matching too much - /\[[^\s:'"`]+:[^\s]+?\[[^\s]+?\][^\s]+?\]/, + /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/, // Utilities regex.pattern([ diff --git a/tests/default-extractor.test.js b/tests/default-extractor.test.js index 13652eee38ca..05a19e62653f 100644 --- a/tests/default-extractor.test.js +++ b/tests/default-extractor.test.js @@ -41,6 +41,9 @@ const htmlExamples = html`
+
+
+