Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge PR #2431: Keep file name and query for fragment-only redirect Location

aiongg2ba2c38d3f3c
diff --cc crates/fetch/src/http.rs
index 5ff6cd74b,4566b3d99..c95478388
--- a/crates/fetch/src/http.rs
+++ b/crates/fetch/src/http.rs
@@@ -173,12 -135,12 +173,16 @@@ impl Url
if l.starts_with('/') {
return Url::parse(&format!("{base}{l}"));
}
+ // empty or fragment-only: the same document
+ if l.is_empty() || l.starts_with('#') {
+ return Ok(self.clone());
+ }
// relative to the current directory
let dir = self.path.split('?').next().unwrap_or("/");
+ // a query-only reference keeps the whole path, file name included (RFC 3986 §5.2.2)
+ if l.starts_with('?') {
+ return Url::parse(&format!("{base}{dir}{l}"));
+ }
let dir = dir.rsplit_once('/').map_or("", |(d, _)| d);
Url::parse(&format!("{base}{dir}/{l}"))
}