Skip to content

Commit 645db11

Browse files
committed
add safety checks around (
There is a situation where classes can exist top-level that are _not_ inside of any type of brackets. E.g.: ``` div class="…" ```
1 parent 29eca2d commit 645db11

File tree

1 file changed

+10
-1
lines changed
  • crates/oxide/src/extractor/pre_processors

1 file changed

+10
-1
lines changed

crates/oxide/src/extractor/pre_processors/slim.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl PreProcessor for Slim {
9292
//
9393
// However, we also need to make sure that we keep the parens that are part of the
9494
// utility class. E.g.: `bg-(--my-color)`.
95-
b'(' if bracket_stack.is_empty() && !matches!(cursor.prev, b'-') => {
95+
b'(' if bracket_stack.is_empty() && !matches!(cursor.prev, b'-' | b'/') => {
9696
result[cursor.pos] = b' ';
9797
bracket_stack.push(cursor.curr);
9898
}
@@ -236,6 +236,15 @@ mod tests {
236236
"bg-[url(https://example.com)]",
237237
],
238238
);
239+
240+
// Top-level class shorthand with parens
241+
let input = r#"
242+
div class="bg-(--my-color) bg-(--my-color)/(--my-opacity)"
243+
"#;
244+
Slim::test_extract_contains(
245+
input,
246+
vec!["bg-(--my-color)", "bg-(--my-color)/(--my-opacity)"],
247+
);
239248
}
240249

241250
#[test]

0 commit comments

Comments
 (0)