mirror of
https://github.com/getzola/zola
synced 2024-12-13 22:02:29 +00:00
Percent decode paths on zola serve
This commit is contained in:
parent
1a36c20bd2
commit
ccad454922
4 changed files with 9 additions and 1 deletions
|
@ -21,6 +21,7 @@ content
|
||||||
- Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore
|
- Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore
|
||||||
- Update clojure syntax
|
- Update clojure syntax
|
||||||
- Prefer extra syntaxes to the default ones if we have a match for language
|
- Prefer extra syntaxes to the default ones if we have a match for language
|
||||||
|
- Fix `zola serve` having issues with non-ascii paths
|
||||||
|
|
||||||
## 0.12.2 (2020-09-28)
|
## 0.12.2 (2020-09-28)
|
||||||
|
|
||||||
|
|
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3263,6 +3263,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"notify",
|
"notify",
|
||||||
"open",
|
"open",
|
||||||
|
"percent-encoding",
|
||||||
"relative-path",
|
"relative-path",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"site",
|
"site",
|
||||||
|
|
|
@ -29,6 +29,7 @@ url = "2"
|
||||||
# Below is for the serve cmd
|
# Below is for the serve cmd
|
||||||
hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] }
|
hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] }
|
||||||
tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs"] }
|
tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs"] }
|
||||||
|
percent-encoding = "2"
|
||||||
notify = "4"
|
notify = "4"
|
||||||
ws = "0.9"
|
ws = "0.9"
|
||||||
ctrlc = "3"
|
ctrlc = "3"
|
||||||
|
|
|
@ -72,8 +72,13 @@ const LIVE_RELOAD: &str = include_str!("livereload.js");
|
||||||
|
|
||||||
async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Response<Body>> {
|
async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Response<Body>> {
|
||||||
let mut path = RelativePathBuf::new();
|
let mut path = RelativePathBuf::new();
|
||||||
|
// https://zola.discourse.group/t/percent-encoding-for-slugs/736
|
||||||
|
let decoded = match percent_encoding::percent_decode_str(req.uri().path()).decode_utf8() {
|
||||||
|
Ok(d) => d,
|
||||||
|
Err(_) => return Ok(not_found()),
|
||||||
|
};
|
||||||
|
|
||||||
for c in req.uri().path().split('/') {
|
for c in decoded.split('/') {
|
||||||
path.push(c);
|
path.push(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue