mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(minifier): constant fold strings with tab char (#8096)
This commit is contained in:
parent
6bd9ddb8b9
commit
b605baa4ac
1 changed files with 2 additions and 6 deletions
|
|
@ -452,14 +452,8 @@ impl<'a, 'b> PeepholeFoldConstants {
|
|||
let left_string = ctx.get_side_free_string_value(left_expr);
|
||||
let right_string = ctx.get_side_free_string_value(right_expr);
|
||||
if let (Some(left_string), Some(right_string)) = (left_string, right_string) {
|
||||
// In JS, browsers parse \v differently. So do not compare strings if one contains \v.
|
||||
if left_string.contains('\u{000B}') || right_string.contains('\u{000B}') {
|
||||
return None;
|
||||
}
|
||||
|
||||
return Some(left_string == right_string);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
ValueType::Undefined | ValueType::Null => Some(true),
|
||||
|
|
@ -812,6 +806,8 @@ mod test {
|
|||
test_same("'' + x <= '' + x"); // potentially foldable
|
||||
test_same("'' + x != '' + x"); // potentially foldable
|
||||
test_same("'' + x === '' + x"); // potentially foldable
|
||||
|
||||
test(r#"if ("string" !== "\u000Bstr\u000Bing\u000B") {}"#, "if (false) {}\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue