Skip to content

Commit

Permalink
chore(tasks): replace \" with single double quote (#2663)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven committed Mar 10, 2024
1 parent a218242 commit 588e946
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tasks/rulegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@ impl<'a> TestCase<'a> {
|| "None".to_string(),
|settings| format!("Some(serde_json::json!({settings}))"),
);
let code_str = if code.contains('"') {
format!("r#\"{}\"#", code.replace("\\\"", "\""))
} else {
format!("\"{code}\"")
};
if need_settings {
format!("(r#\"{code}\"#, {config}, {settings})")
format!("({code_str}, {config}, {settings})")
} else if need_config {
format!("(r#\"{code}\"#, {config})")
format!("({code_str}, {config})")
} else {
format!("r#\"{code}\"#")
code_str.to_string()
}
})
.unwrap_or_default()
Expand Down

0 comments on commit 588e946

Please sign in to comment.