Skip to content

Commit e52c51a

Browse files
author
Roy Assis
committed
Update _remove_prefix method to iterativly remove prefix by regex
1 parent 117e79e commit e52c51a

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
@@ -654,8 +654,10 @@ def _remove_prefix(self, path: str) -> str:
654654
for prefix in self._strip_prefixes:
655655
if path == prefix:
656656
return "/"
657-
if self._path_starts_with(path, prefix):
658-
return path[len(prefix) :]
657+
path = re.sub(rf"^/?({prefix})/", r"/", path)
658+
659+
if not path:
660+
path = "/"
659661

660662
return path
661663

0 commit comments

Comments
 (0)