(dir: &str)
| 83 | } |
| 84 | |
| 85 | fn parent_dir(dir: &str) -> Option<String> { |
| 86 | if dir.is_empty() { return None; } |
| 87 | let trimmed = dir.trim_end_matches('/'); |
| 88 | // URL guard: never strip the host. After "scheme://" there must still be a '/' to walk into. |
| 89 | if let Some(scheme_end) = trimmed.find("://") { |
| 90 | let after = &trimmed[scheme_end + 3..]; |
| 91 | if !after.contains('/') { return None; } |
| 92 | } |
| 93 | match trimmed.rsplit_once('/') { |
| 94 | Some(("", _)) => Some(String::new()), |
| 95 | Some((head, _)) => Some(s!(str head, "/")), |
| 96 | None => Some(String::new()), |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | struct Reader<'a> { |
| 101 | src: &'a [u8], |
no test coverage detected