diff options
Diffstat (limited to '')
-rw-r--r-- | src/listing.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/listing.rs b/src/listing.rs index b58d765..0ffa2df 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -5,7 +5,7 @@ use actix_web::web::Query; use actix_web::{HttpRequest, HttpResponse, Result}; use bytesize::ByteSize; use htmlescape::encode_minimal as escape_html_entity; -use percent_encoding::{utf8_percent_encode, percent_decode_str, AsciiSet, CONTROLS}; +use percent_encoding::{percent_decode_str, utf8_percent_encode, AsciiSet, CONTROLS}; use qrcodegen::{QrCode, QrCodeEcc}; use serde::Deserialize; use std::io; @@ -165,10 +165,14 @@ pub fn directory_listing( let base = Path::new(serve_path); let random_route = format!("/{}", random_route.unwrap_or_default()); let is_root = base.parent().is_none() || Path::new(&req.path()) == Path::new(&random_route); + let encoded_dir = match base.strip_prefix(random_route) { Ok(c_d) => Path::new("/").join(c_d), Err(_) => base.to_path_buf(), - }.display().to_string(); + } + .display() + .to_string(); + let display_dir = { let decoded = percent_decode_str(&encoded_dir).decode_utf8_lossy(); if is_root { |