Skip to content

Commit

Permalink
Update _remove_prefix method to iterativly remove prefix by regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Assis authored and rubenfonseca committed Aug 10, 2023
1 parent 87c3456 commit 766f525
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,10 @@ def _remove_prefix(self, path: str) -> str:
for prefix in self._strip_prefixes:
if path == prefix:
return "/"
if self._path_starts_with(path, prefix):
return path[len(prefix) :]
path = re.sub(rf"^/?({prefix})/", r"/", path)

if not path:
path = "/"

return path

Expand Down

0 comments on commit 766f525

Please sign in to comment.