From 3a031e78a8fd966bd3f4c209556f16fd34902b97 Mon Sep 17 00:00:00 2001 From: Lukas Stabe Date: Fri, 21 Aug 2020 07:02:33 +0200 Subject: make linter happy --- src/listing.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 { -- cgit v1.2.3