diff options
author | Silux <silux@silux.ink> | 2023-02-22 12:24:46 +0000 |
---|---|---|
committer | Silux <silux@silux.ink> | 2023-02-22 12:24:46 +0000 |
commit | 27702d6687e40663f47c5445a4415365d116651f (patch) | |
tree | 6ae93ce500e2ab04cd60acd0153e5b56e254518c /src/listing.rs | |
parent | Make the wget footer click to copy (diff) | |
download | miniserve-27702d6687e40663f47c5445a4415365d116651f.tar.gz miniserve-27702d6687e40663f47c5445a4415365d116651f.zip |
Switched from using AsRef<str> to using &Uri
I honestly just switched the definition and then frantically
changed small things based on rusts error messages, but it passes
fmt, clippy and tests so I think it's fine.
This allow a bit finer control over the URI, but is honetly a bit insignificant.
Diffstat (limited to '')
-rw-r--r-- | src/listing.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/listing.rs b/src/listing.rs index a62c969..e360368 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -163,12 +163,12 @@ pub fn directory_listing( let base = Path::new(serve_path); let random_route_abs = format!("/{}", conf.route_prefix); - let abs_url = format!( - "{}://{}{}", - req.connection_info().scheme(), - req.connection_info().host(), - req.uri() - ); + let abs_uri = http::Uri::builder() + .scheme(req.connection_info().scheme()) + .authority(req.connection_info().host()) + .path_and_query(req.uri().to_string()) + .build() + .unwrap(); let is_root = base.parent().is_none() || Path::new(&req.path()) == Path::new(&random_route_abs); let encoded_dir = match base.strip_prefix(random_route_abs) { @@ -379,7 +379,7 @@ pub fn directory_listing( renderer::page( entries, readme, - abs_url, + &abs_uri, is_root, query_params, &breadcrumbs, |