(href: &str)
| 3 | pub mod storage; |
| 4 | |
| 5 | fn normalize_href_impl(href: &str) -> String { |
| 6 | let trimmed = href.trim(); |
| 7 | let path = trimmed.split(['?', '#']).next().unwrap_or("/").trim(); |
| 8 | let core = if path.is_empty() { "/" } else { path }; |
| 9 | let mut normalized = if core.starts_with('/') { |
| 10 | core.to_string() |
| 11 | } else { |
| 12 | format!("/{core}") |
| 13 | }; |
| 14 | if normalized.len() > "/index.html".len() && normalized.ends_with("/index.html") { |
| 15 | normalized.truncate(normalized.len() - "/index.html".len()); |
| 16 | } |
| 17 | while normalized.len() > 1 && normalized.ends_with('/') { |
| 18 | normalized.pop(); |
| 19 | } |
| 20 | if normalized.is_empty() { |
| 21 | normalized.push('/'); |
| 22 | } |
| 23 | normalized |
| 24 | } |
| 25 | |
| 26 | fn split_href_impl(href: &str) -> Vec<String> { |
| 27 | let normalized = normalize_href_impl(href); |
no test coverage detected