aboutsummaryrefslogtreecommitdiffstats
path: root/src/listing.rs
diff options
context:
space:
mode:
authorjikstra <jikstra@disroot.org>2021-12-29 03:10:24 +0000
committerjikstra <jikstra@disroot.org>2021-12-29 03:10:24 +0000
commit2103ea0ed4df223b238dda96f142814692ed861d (patch)
treef958110b72123a8172ad93fc8df7bb534e862ecc /src/listing.rs
parentMerge pull request #678 from svenstaro/dependabot/cargo/clap_generate-3.0.0-rc.9 (diff)
downloadminiserve-2103ea0ed4df223b238dda96f142814692ed861d.tar.gz
miniserve-2103ea0ed4df223b238dda96f142814692ed861d.zip
Implement --route-prefix to set specific route prefix
Diffstat (limited to '')
-rw-r--r--src/listing.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/listing.rs b/src/listing.rs
index 9273025..4360c87 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -162,7 +162,7 @@ pub fn directory_listing(
let serve_path = req.path();
let base = Path::new(serve_path);
- let random_route_abs = format!("/{}", conf.random_route.clone().unwrap_or_default());
+ let random_route_abs = format!("/{}", conf.route_prefix);
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) {
@@ -181,10 +181,8 @@ pub fn directory_listing(
let decoded = percent_decode_str(&encoded_dir).decode_utf8_lossy();
let mut res: Vec<Breadcrumb> = Vec::new();
- let mut link_accumulator = match &conf.random_route {
- Some(random_route) => format!("/{}/", random_route),
- None => "/".to_string(),
- };
+
+ let mut link_accumulator = format!("{}/", &conf.route_prefix);
let mut components = Path::new(&*decoded).components().peekable();