Skip to content

Commit

Permalink
fix(es/codegen): Fix replacement when inline_script is on (#8659)
Browse files Browse the repository at this point in the history
  • Loading branch information
xc2 authored Feb 26, 2024
1 parent 3258bf4 commit e179134
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ where
if self.cfg.inline_script {
value = replace_close_inline_script(&value)
.replace("\x3c!--", "\\x3c!--")
.replace("/--\x3e/", "--\\x3e");
.replace("--\x3e", "--\\x3e");
}

self.wr.write_str_lit(DUMMY_SP, &value)?;
Expand Down
3 changes: 2 additions & 1 deletion crates/swc_ecma_minifier/tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ fn assert_format(src: &str, expected: &str, opts: Config) {
fn inline_script() {
let src = r#"
console.log("</sCrIpT>");
foo("/-->/");
"#;
let expected = r#"console.log("<\/sCrIpT>");"#;
let expected = r#"console.log("<\/sCrIpT>");foo("/--\x3e/");"#;
assert_format(
src,
expected,
Expand Down

0 comments on commit e179134

Please sign in to comment.