From cf1a248538960ac7794e34aa518f5c9044d2df76 Mon Sep 17 00:00:00 2001 From: Joe Kaufeld Date: Wed, 11 Jun 2025 22:18:33 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20add=20flag=20for=20fixing=20rout?= =?UTF-8?q?es=20not=20prefixed=20with=20a=20slash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spiderweb/routes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spiderweb/routes.py b/spiderweb/routes.py index 8286957..74f424c 100644 --- a/spiderweb/routes.py +++ b/spiderweb/routes.py @@ -40,6 +40,7 @@ class RoutesMixin: _error_routes: dict error_routes: dict[int, Callable] append_slash: bool + fix_route_starting_slash: bool def route(self, path, allowed_methods=None, name=None) -> Callable: """ @@ -134,7 +135,8 @@ class RoutesMixin: or allowed_methods or DEFAULT_ALLOWED_METHODS ) - + if not path.startswith("/") and self.fix_route_starting_slash: + path = "/" + path reverse_path = re.sub(r"<(.*?):(.*?)>", r"{\2}", path) if "<" in path else path def get_packet(func):