When trying to parse a windows-style file: URL that contains a hostname, that hostname is removed from the resulting URL:
use url::Url; // 2.5.8
fn main() {
println!("{}", Url::parse("file://irgendwo/I:/m/nirgendwo").unwrap());
// prints file:///I:/m/nirgendwo
}
When we use a Unix-style URL (file://irgendwo/im/nirgendwo), it is returned unmodified (i.e. including the hostname).
We can, however, construct a Windows-style URL manually using .set_host():
use url::Url; // 2.5.8
fn main() {
let mut url = Url::parse("file:///I:/m/nirgendwo").unwrap();
url.set_host(Some("irgendwo"));
println!("{url}");
// prints file://irgendwo/I:/m/nirgendwo
}
When trying to parse a windows-style
file:URL that contains a hostname, that hostname is removed from the resulting URL:When we use a Unix-style URL (
file://irgendwo/im/nirgendwo), it is returned unmodified (i.e. including the hostname).We can, however, construct a Windows-style URL manually using
.set_host():