From b605baa4acc1a9dc63bbb5acae28f60a90c2b43e Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:15:06 +0000 Subject: [PATCH] fix(minifier): constant fold strings with tab char (#8096) --- .../src/ast_passes/peephole_fold_constants.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs b/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs index f79336b4b..82f7e50cc 100644 --- a/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs +++ b/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs @@ -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 (" str ing " !== "\u000Bstr\u000Bing\u000B") {}"#, "if (false) {}\n"); } #[test]