mirror of https://github.com/Tim-Paik/srv.git
v1.0.0-rc.5 fixed undecode url and try to statically link msvc runtime
This commit is contained in:
parent
757a2943f4
commit
62fd879e53
|
@ -0,0 +1,2 @@
|
|||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
|
@ -17,16 +17,20 @@ jobs:
|
|||
upload-assets:
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
include:
|
||||
- target: x86_64-unknown-linux-musl
|
||||
os: ubuntu-latest
|
||||
- target: x86_64-apple-darwin
|
||||
os: macos-latest
|
||||
- target: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: taiki-e/upload-rust-binary-action@v1
|
||||
with:
|
||||
bin: srv
|
||||
target: ${{ matrix.target }}
|
||||
tar: unix
|
||||
zip: windows
|
||||
env:
|
||||
|
|
|
@ -1904,6 +1904,7 @@ dependencies = [
|
|||
"sha2",
|
||||
"tera",
|
||||
"toml",
|
||||
"urlencoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2381,6 +2382,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
|
||||
|
||||
[[package]]
|
||||
name = "v_escape"
|
||||
version = "0.15.0"
|
||||
|
|
|
@ -22,6 +22,7 @@ serde = "1"
|
|||
sha2 = "0.9"
|
||||
tera = "1"
|
||||
toml = "0.5"
|
||||
urlencoding = "2.1"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -180,9 +180,9 @@ struct File {
|
|||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct IndexContext<'r> {
|
||||
title: &'r str,
|
||||
paths: Vec<&'r str>,
|
||||
struct IndexContext {
|
||||
title: String,
|
||||
paths: Vec<String>,
|
||||
dirs: Vec<Dir>,
|
||||
files: Vec<File>,
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ fn render_index(
|
|||
}
|
||||
let show_dot_files = var("DOTFILES").unwrap_or("false".to_string()) == "true";
|
||||
let mut context = IndexContext {
|
||||
title: "",
|
||||
title: "".to_string(),
|
||||
paths: vec![],
|
||||
dirs: vec![],
|
||||
files: vec![],
|
||||
|
@ -220,6 +220,9 @@ fn render_index(
|
|||
if path == "" {
|
||||
continue;
|
||||
}
|
||||
let path =
|
||||
urlencoding::decode(path).unwrap_or(std::borrow::Cow::Borrowed("[Parse URL Error]"));
|
||||
let path = path.into_owned();
|
||||
context.paths.push(path);
|
||||
}
|
||||
match read_dir(&dir.path) {
|
||||
|
@ -276,7 +279,7 @@ fn render_index(
|
|||
}
|
||||
}
|
||||
}
|
||||
context.title = context.paths.last().unwrap_or(&"/");
|
||||
context.title = context.paths.last().unwrap_or(&"/".to_string()).to_string();
|
||||
context.dirs.sort();
|
||||
context.files.sort();
|
||||
let content = tera::Context::from_serialize(&context);
|
||||
|
@ -632,7 +635,11 @@ async fn main() -> std::io::Result<()> {
|
|||
} else {
|
||||
process_time
|
||||
});
|
||||
let content = blue.value(data[4]);
|
||||
let content = blue.value(
|
||||
urlencoding::decode(data[4])
|
||||
.unwrap_or(std::borrow::Cow::Borrowed("[Parse URL Error]"))
|
||||
.into_owned(),
|
||||
);
|
||||
return writeln!(
|
||||
buf,
|
||||
"[{}] {} | {} | {} | {}",
|
||||
|
|
Loading…
Reference in New Issue