From 594d57c89c80e1670fe07b5842626dc3a074dba2 Mon Sep 17 00:00:00 2001 From: Dominic Zimmer Date: Thu, 16 Apr 2020 23:54:06 +0200 Subject: [PATCH] 303 if trailing slash is missing --- main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.py b/main.py index 0f292ed..5ec5337 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,13 @@ def get_client(request: aiohttp.web.Request): return client +@routes.get(CLIENT_REGEX) +async def handler(request: aiohttp.web.Request): + # this handler prevents people missing trailing slashes + client = get_client(request) + raise aiohttp.web.HTTPFound(f"/{client}/") + + @routes.get(CLIENT_REGEX + '/') async def handler(request: aiohttp.web.Request): client = get_client(request)