(
segments: &[Vec<u8>],
_trailing_slash_hint: bool,
opts: CanonicalizeOptions,
)
| 265 | } |
| 266 | |
| 267 | fn build_canonical_path( |
| 268 | segments: &[Vec<u8>], |
| 269 | _trailing_slash_hint: bool, |
| 270 | opts: CanonicalizeOptions, |
| 271 | ) -> String { |
| 272 | let mut out = String::from("/"); |
| 273 | for (idx, seg) in segments.iter().enumerate() { |
| 274 | if idx > 0 { |
| 275 | out.push('/'); |
| 276 | } |
| 277 | let trimmed: &[u8] = if opts.strip_path_parameters { |
| 278 | match seg.iter().position(|&b| b == b';') { |
| 279 | Some(pos) => &seg[..pos], |
| 280 | None => seg, |
| 281 | } |
| 282 | } else { |
| 283 | seg |
| 284 | }; |
| 285 | for &b in trimmed { |
| 286 | if b == ENCODED_SLASH_SENTINEL { |
| 287 | out.push_str("%2F"); |
| 288 | } else if is_pchar_unreserved(b) { |
| 289 | out.push(b as char); |
| 290 | } else { |
| 291 | out.push('%'); |
| 292 | out.push(upper_hex_nibble(b >> 4)); |
| 293 | out.push(upper_hex_nibble(b & 0x0F)); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | out |
| 298 | } |
| 299 | |
| 300 | fn is_pchar_unreserved(b: u8) -> bool { |
| 301 | // RFC 3986 pchar without the percent-encoded slot — i.e. bytes we emit |
no test coverage detected