pub fn normalize_link_target(href: &str) -> StringExpand description
Normalizes an authored link target (href) into the request-path form that
resolve_request_path expects.
Live requests reach the server through axum’s extract::Path, which
percent-decodes the URL path before resolve_request_path ever sees it.
Any code that feeds authored hrefs (still percent-encoded, possibly
carrying fragments or query strings) into the resolver must apply this
identical normalization, or its results diverge from what the server
actually serves. That divergence previously caused bogus “broken internal
link” 404 reports in the GUI error panel for links like
/IronCore%20Swag%20T-shirts%20Gifts/ pointing at
IronCore Swag T-shirts Gifts.md.
Mirrors exactly what a real HTTP request undergoes:
- Strip the fragment (
#...), then the query string (?...). - Percent-decode (lossy UTF-8, matching axum’s decoding).
- Trim leading and trailing
/.
Note: valid percent escapes are always decoded, so a literal % must be
authored as %25 (e.g. 100%25 normalizes to 100%).