mirror of
https://github.com/openwrt/packages.git
synced 2025-12-10 12:41:22 +00:00
38 lines
1.4 KiB
Diff
38 lines
1.4 KiB
Diff
From b2f244a4cfeb492b38ad9b92692e230e04540ea0 Mon Sep 17 00:00:00 2001
|
|
From: sigoden <sigoden@gmail.com>
|
|
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(-)
|
|
|
|
--- a/src/noscript.rs
|
|
+++ b/src/noscript.rs
|
|
@@ -55,17 +55,20 @@ pub fn generate_noscript_html(data: &Ind
|
|
|
|
fn render_parent() -> String {
|
|
let value = "../";
|
|
- format!("<tr><td><a href=\"{value}\">{value}</a></td><td></td><td></td></tr>")
|
|
+ format!("<tr><td><a href=\"{value}?noscript\">{value}</a></td><td></td><td></td></tr>")
|
|
}
|
|
|
|
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!("<tr><td><a href=\"{href}{suffix}\">{name}{suffix}</a></td><td>{mtime}</td><td>{size}</td></tr>")
|
|
+ format!("<tr><td><a href=\"{href}\">{name}</a></td><td>{mtime}</td><td>{size}</td></tr>")
|
|
}
|
|
|
|
fn format_mtime(mtime: u64) -> Option<String> {
|