Ref: https://wicg.github.io/urlpattern/#escape-a-pattern-string
(input: &str)
| 298 | |
| 299 | // Ref: https://wicg.github.io/urlpattern/#escape-a-pattern-string |
| 300 | pub 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 | } |
no outgoing calls
no test coverage detected