Skip to content

Commit 2a7e2b6

Browse files
Roy Assisrubenfonseca
Roy Assis
authored andcommitted
Update _remove_prefix method to iterativly remove prefix by regex
1 parent d2ebd0d commit 2a7e2b6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,10 @@ def _remove_prefix(self, path: str) -> str:
709709
for prefix in self._strip_prefixes:
710710
if path == prefix:
711711
return "/"
712-
if self._path_starts_with(path, prefix):
713-
return path[len(prefix) :]
712+
path = re.sub(rf"^/?({prefix})/", r"/", path)
713+
714+
if not path:
715+
path = "/"
714716

715717
return path
716718

0 commit comments

Comments
 (0)