Version
http v1.4.1
Platform
Linux 6.8.0-111-generic Ubuntu 24.04
Summary
Uri Builder path change broke parsing and reconstructing the Uri with empty path.
In example below the path returns empty string.
This used to work fine to sanitize/cleanup a provided Url string, which I think is a common pattern people use.
As Uri.path() always returns a string and not an Option<String> its not intuitive that this stops working.
Also what is a bit annoying is that this broke in a patch update version.
Took me a while to figure out that an auto update of this dependency broke this behavior.
Code Sample
let uri = Uri::from_str("example.com")?;
let final_uri = Uri::builder()
.scheme(uri.scheme_str().unwrap_or("https"))
.authority(uri.authority()?.as_str())
.path_and_query(uri.path())
.build();
Expected Behavior
In v1.4.0 this used to work.
Actual Behavior
Since v1.4.1 this fails now.
final_uri = Err(http::Error(InvalidUri(Empty)))
Additional Context
If this is just intended and works as designed then feel free to close this.
Workaround I needed to add:
let path = if !path.starts_with("/") {
"/".to_string() + path
} else {
path.to_string()
};
Version
http v1.4.1
Platform
Linux 6.8.0-111-generic Ubuntu 24.04
Summary
Uri Builder path change broke parsing and reconstructing the Uri with empty path.
In example below the path returns empty string.
This used to work fine to sanitize/cleanup a provided Url string, which I think is a common pattern people use.
As
Uri.path()always returns a string and not anOption<String>its not intuitive that this stops working.Also what is a bit annoying is that this broke in a patch update version.
Took me a while to figure out that an auto update of this dependency broke this behavior.
Code Sample
Expected Behavior
In v1.4.0 this used to work.
Actual Behavior
Since v1.4.1 this fails now.
Additional Context
If this is just intended and works as designed then feel free to close this.
Workaround I needed to add: