From 5f923822fe881c42c054b730a2a5ee34c10045c8 Mon Sep 17 00:00:00 2001 From: Jecket <35532868+Jecket22@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:07:31 +0100 Subject: [PATCH] expunge slashes the other way around --- src/server.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server.cr b/src/server.cr index 1ecf8c9..dc8c068 100644 --- a/src/server.cr +++ b/src/server.cr @@ -7,6 +7,8 @@ module CrystalGauntlet::Server def call(context : HTTP::Server::Context) # expunge trailing slashes path = context.request.path.chomp("/") + # remove slashes at the beginning of the path, if there are more than one + path = path.sub(/^\/*(?!\/)/, "/") path = path.sub(config_get("general.append_path").as(String | Nil) || "", "") @@ -29,7 +31,7 @@ module CrystalGauntlet::Server end end context.response.content_type = "text/plain" - context.response.respond_with_status(500, "-1") + context.response.respond_with_status(500, "uh oh!!! server did a fucky wucky") else max_size = 2048