Skip to content

Commit 766f525

Browse files
Roy Assisrubenfonseca
Roy Assis
authored andcommitted
Update _remove_prefix method to iterativly remove prefix by regex
1 parent 87c3456 commit 766f525

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
@@ -715,8 +715,10 @@ def _remove_prefix(self, path: str) -> str:
715715
for prefix in self._strip_prefixes:
716716
if path == prefix:
717717
return "/"
718-
if self._path_starts_with(path, prefix):
719-
return path[len(prefix) :]
718+
path = re.sub(rf"^/?({prefix})/", r"/", path)
719+
720+
if not path:
721+
path = "/"
720722

721723
return path
722724

0 commit comments

Comments
 (0)