fix: for html paths, .html suffix should be appended automatically (#1015)

* fix: for html paths, .html suffix should be appended automatically

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
r0.7
Meng Zhang 2023-12-10 23:58:21 +08:00 committed by GitHub
parent 86a8612750
commit 34842141e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -37,10 +37,8 @@ pub async fn handler(uri: Uri) -> impl IntoResponse {
let mut path = uri.path().trim_start_matches('/').to_string();
if path.is_empty() {
path = "index.html".to_owned()
} else if path == "playground" {
path = "playground.html".to_owned();
} else if path == "swagger" {
path = "swagger.html".to_owned();
} else if !path.contains('.') && WebAssets::get(&format!("{}.html", path)).is_some() {
path += ".html"
}
WebStaticFile(path)
}