(input: &str)
| 168 | } |
| 169 | |
| 170 | fn url_encode(input: &str) -> String { |
| 171 | let mut encoded = String::new(); |
| 172 | for b in input.bytes() { |
| 173 | match b { |
| 174 | b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => { |
| 175 | encoded.push(b as char); |
| 176 | } |
| 177 | _ => { |
| 178 | encoded.push_str(&format!("%{:02X}", b)); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | encoded |
| 183 | } |
| 184 | |
| 185 | /// Extract the `@url` / `@navigate` auto-navigation target from a script's |
| 186 | /// leading comment block, if present. |