From 2a5f5783d60bdb476352f3087bd77ea271338822 Mon Sep 17 00:00:00 2001 From: delthas Date: Wed, 13 Apr 2022 14:45:02 +0200 Subject: [PATCH] Fix stripping trailing slashes of URLs Most URLs ending with a trailing slash currently 404, because the strict mode is not properly disabled in the app. The strict_slashes value must be set before adding the routes. After this patch, requesting URLs with a trailing slash will work as expected (eg git.sr.ht/~sircmpwn/git.sr.ht/) --- gitsrht/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitsrht/app.py b/gitsrht/app.py index ebfbbc7..eaae395 100644 --- a/gitsrht/app.py +++ b/gitsrht/app.py @@ -20,6 +20,8 @@ class GitApp(SrhtFlask): super().__init__("git.sr.ht", __name__, oauth_service=oauth_service) + self.url_map.strict_slashes = False + from gitsrht.blueprints.auth import auth from gitsrht.blueprints.public import public from gitsrht.blueprints.api import register_api @@ -77,8 +79,6 @@ class GitApp(SrhtFlask): os.path.dirname(__file__), "templates"))] self.jinja_loader = ChoiceLoader(choices) - self.url_map.strict_slashes = False - def lookup_user(self, email): return User.query.filter(User.email == email).one_or_none() -- 2.38.4