From 27702d6687e40663f47c5445a4415365d116651f Mon Sep 17 00:00:00 2001 From: Silux Date: Wed, 22 Feb 2023 13:24:46 +0100 Subject: Switched from using AsRef 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. --- src/listing.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/listing.rs') 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, -- cgit v1.2.3