MCPcopy Create free account
hub / github.com/PerroEngine/Perro / normalize_href_impl

Function normalize_href_impl

perro_source/api_modules/perro_web/src/lib.rs:5–24  ·  view source on GitHub ↗
(href: &str)

Source from the content-addressed store, hash-verified

3pub mod storage;
4
5fn 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
26fn split_href_impl(href: &str) -> Vec<String> {
27 let normalized = normalize_href_impl(href);

Callers 5

split_href_implFunction · 0.85
set_pending_route_changeFunction · 0.85
normalize_hrefFunction · 0.85
current_href_implFunction · 0.85
push_route_implFunction · 0.85

Calls 5

nextMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
popMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected