Skip to main content

escape_js_string

Function escape_js_string 

Source
pub fn escape_js_string(s: &str) -> String
Expand description

Escape a string for safe interpolation into a JS single-quoted literal.

Handles \, ', `, \n, \r, and \t — the characters that would break a single-quoted JS string or template literal.