mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
do not redirect on empty path
also fixed the check for a trailing slash
This commit is contained in:
parent
80286a59fa
commit
a515d508ac
1 changed files with 4 additions and 2 deletions
|
|
@ -156,10 +156,12 @@ async fn send_response<W: Write + Unpin>(url: Url, stream: &mut W) -> Result {
|
||||||
path.extend(segments);
|
path.extend(segments);
|
||||||
}
|
}
|
||||||
if async_std::fs::metadata(&path).await?.is_dir() {
|
if async_std::fs::metadata(&path).await?.is_dir() {
|
||||||
if url.as_str().ends_with('/') {
|
if url.path().ends_with('/') || url.path().is_empty() {
|
||||||
|
// if the path ends with a slash or the path is empty, the links will work the same
|
||||||
|
// without a redirect
|
||||||
path.push("index.gmi");
|
path.push("index.gmi");
|
||||||
} else {
|
} else {
|
||||||
// Send a redirect when the URL for a directory has no trailing slash.
|
// if client is not redirected, links may not work as expected without trailing slash
|
||||||
return respond(stream, "31", &[url.as_str(), "/"]).await;
|
return respond(stream, "31", &[url.as_str(), "/"]).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue