From b2f244a4cfeb492b38ad9b92692e230e04540ea0 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 16 Aug 2025 07:36:19 +0800 Subject: [PATCH] feat: make dir urls inherit `?noscript` params (#614) --- src/noscript.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/noscript.rs b/src/noscript.rs index d40a0f7..f89f204 100644 --- a/src/noscript.rs +++ b/src/noscript.rs @@ -55,17 +55,20 @@ pub fn generate_noscript_html(data: &IndexData) -> Result { fn render_parent() -> String { let value = "../"; - format!("{value}") + format!("{value}") } fn render_path_item(path: &PathItem) -> String { - let href = encode_uri(&path.name); - let suffix = if path.path_type.is_dir() { "/" } else { "" }; - let name = escape_str_pcdata(&path.name); + let mut href = encode_uri(&path.name); + let mut name = escape_str_pcdata(&path.name).to_string(); + if path.path_type.is_dir() { + href.push_str("/?noscript"); + name.push('/'); + }; let mtime = format_mtime(path.mtime).unwrap_or_default(); let size = format_size(path.size, path.path_type); - format!("{name}{suffix}{mtime}{size}") + format!("{name}{mtime}{size}") } fn format_mtime(mtime: u64) -> Option {