Skip to content

Commit 8ee0ba8

Browse files
committed
add a "//" check for perf reasons (4x faster for non-// routes)
1 parent f635bd6 commit 8ee0ba8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

aikido_zen/helpers/try_parse_url_path.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ def try_parse_url_path(url):
2828
if parsed.path == "":
2929
return "/"
3030

31-
# Multiple slashes are ignored in python, so we want to also remove them here
32-
# This allows the route building & endpoint matching to work properly.
33-
normalized_path = re.sub(r"/+", "/", parsed.path)
31+
normalized_path = parsed.path
32+
if "//" in normalized_path:
33+
# Multiple slashes are ignored in python, so we want to also remove them here
34+
# This allows the route building & endpoint matching to work properly.
35+
normalized_path = re.sub(r"/+", "/", normalized_path)
3436

3537
return normalized_path

0 commit comments

Comments
 (0)