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:
|
upload-assets:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
include:
|
||||||
- ubuntu-latest
|
- target: x86_64-unknown-linux-musl
|
||||||
- macos-latest
|
os: ubuntu-latest
|
||||||
- windows-latest
|
- target: x86_64-apple-darwin
|
||||||
|
os: macos-latest
|
||||||
|
- target: x86_64-pc-windows-msvc
|
||||||
|
os: windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: taiki-e/upload-rust-binary-action@v1
|
- uses: taiki-e/upload-rust-binary-action@v1
|
||||||
with:
|
with:
|
||||||
bin: srv
|
bin: srv
|
||||||
|
target: ${{ matrix.target }}
|
||||||
tar: unix
|
tar: unix
|
||||||
zip: windows
|
zip: windows
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -1904,6 +1904,7 @@ dependencies = [
|
||||||
"sha2",
|
"sha2",
|
||||||
"tera",
|
"tera",
|
||||||
"toml",
|
"toml",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2381,6 +2382,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "v_escape"
|
name = "v_escape"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
|
|
|
@ -22,6 +22,7 @@ serde = "1"
|
||||||
sha2 = "0.9"
|
sha2 = "0.9"
|
||||||
tera = "1"
|
tera = "1"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
|
urlencoding = "2.1"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -180,9 +180,9 @@ struct File {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct IndexContext<'r> {
|
struct IndexContext {
|
||||||
title: &'r str,
|
title: String,
|
||||||
paths: Vec<&'r str>,
|
paths: Vec<String>,
|
||||||
dirs: Vec<Dir>,
|
dirs: Vec<Dir>,
|
||||||
files: Vec<File>,
|
files: Vec<File>,
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ fn render_index(
|
||||||
}
|
}
|
||||||
let show_dot_files = var("DOTFILES").unwrap_or("false".to_string()) == "true";
|
let show_dot_files = var("DOTFILES").unwrap_or("false".to_string()) == "true";
|
||||||
let mut context = IndexContext {
|
let mut context = IndexContext {
|
||||||
title: "",
|
title: "".to_string(),
|
||||||
paths: vec![],
|
paths: vec![],
|
||||||
dirs: vec![],
|
dirs: vec![],
|
||||||
files: vec![],
|
files: vec![],
|
||||||
|
@ -220,6 +220,9 @@ fn render_index(
|
||||||
if path == "" {
|
if path == "" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let path =
|
||||||
|
urlencoding::decode(path).unwrap_or(std::borrow::Cow::Borrowed("[Parse URL Error]"));
|
||||||
|
let path = path.into_owned();
|
||||||
context.paths.push(path);
|
context.paths.push(path);
|
||||||
}
|
}
|
||||||
match read_dir(&dir.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.dirs.sort();
|
||||||
context.files.sort();
|
context.files.sort();
|
||||||
let content = tera::Context::from_serialize(&context);
|
let content = tera::Context::from_serialize(&context);
|
||||||
|
@ -632,7 +635,11 @@ async fn main() -> std::io::Result<()> {
|
||||||
} else {
|
} else {
|
||||||
process_time
|
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!(
|
return writeln!(
|
||||||
buf,
|
buf,
|
||||||
"[{}] {} | {} | {} | {}",
|
"[{}] {} | {} | {} | {}",
|
||||||
|
|
Loading…
Reference in New Issue