Skip to content

Commit a9b41ad

Browse files
committed
avoid folder redirects for .SQL files (in capital letters)
1 parent 18cdb63 commit a9b41ad

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/webserver/http.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@ fn req_path(req: &ServiceRequest) -> Cow<'_, str> {
475475

476476
fn redirect_missing_trailing_slash(uri: &Uri) -> Option<HttpResponse> {
477477
let path = uri.path();
478-
if !path.ends_with('/') && !path.ends_with(".sql") {
478+
if !path.ends_with('/')
479+
&& !path
480+
.rsplit_once('.')
481+
.is_some_and(|(_, ext)| ext.eq_ignore_ascii_case("sql"))
482+
{
479483
let mut redirect_path = path.to_owned();
480484
redirect_path.push('/');
481485
if let Some(query) = uri.query() {
@@ -485,8 +489,7 @@ fn redirect_missing_trailing_slash(uri: &Uri) -> Option<HttpResponse> {
485489
Some(
486490
HttpResponse::MovedPermanently()
487491
.insert_header((header::LOCATION, redirect_path))
488-
.finish()
489-
.into(),
492+
.finish(),
490493
)
491494
} else {
492495
None

0 commit comments

Comments
 (0)