MCPcopy Create free account
hub / github.com/denoland/rust-urlpattern / escape_pattern_string

Function escape_pattern_string

src/canonicalize_and_process.rs:300–310  ·  view source on GitHub ↗

Ref: https://wicg.github.io/urlpattern/#escape-a-pattern-string

(input: &str)

Source from the content-addressed store, hash-verified

298
299// Ref: https://wicg.github.io/urlpattern/#escape-a-pattern-string
300pub fn escape_pattern_string(input: &str) -> String {
301 assert!(input.is_ascii());
302 let mut result = String::new();
303 for char in input.chars() {
304 if matches!(char, '+' | '*' | '?' | ':' | '{' | '}' | '(' | ')' | '\\') {
305 result.push('\\');
306 }
307 result.push(char);
308 }
309 result
310}

Callers 2

process_base_urlFunction · 0.85
generate_pattern_stringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected