Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clip unbalanced closing brackets in arbitrary values #9973

Merged
merged 2 commits into from Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add container queries plugin to standalone CLI ([#9865](https://github.com/tailwindlabs/tailwindcss/pull/9865))
- Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944))
- Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972))
- Clip unbalanced brackets in arbitrary values ([#9973](https://github.com/tailwindlabs/tailwindcss/pull/9973))

## [3.2.4] - 2022-11-11

Expand Down
2 changes: 1 addition & 1 deletion src/lib/defaultExtractor.js
Expand Up @@ -184,7 +184,7 @@ function clipAtBalancedParens(input) {
// This means that there was an extra closing `]`
// We'll clip to just before it
if (depth < 0) {
return input.substring(0, match.index)
return input.substring(0, match.index - 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, yep that will do it!

}

// We've finished balancing the brackets but there still may be characters that can be included
Expand Down
6 changes: 6 additions & 0 deletions tests/default-extractor.test.js
Expand Up @@ -482,3 +482,9 @@ test('a lot of data', () => {

expect(extractions).toContain(`underline`)
})

test('ruby percent string array', () => {
let extractions = defaultExtractor('%w[text-[#bada55]]')

expect(extractions).toContain(`text-[#bada55]`)
})