Skip to content

Commit d4b759f

Browse files
Roy Assisrubenfonseca
Roy Assis
authored andcommitted
Update _remove_prefix method to iterativly remove prefix by regex
1 parent 9b59ba5 commit d4b759f

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
@@ -690,8 +690,10 @@ def _remove_prefix(self, path: str) -> str:
690690
for prefix in self._strip_prefixes:
691691
if path == prefix:
692692
return "/"
693-
if self._path_starts_with(path, prefix):
694-
return path[len(prefix) :]
693+
path = re.sub(rf"^/?({prefix})/", r"/", path)
694+
695+
if not path:
696+
path = "/"
695697

696698
return path
697699

0 commit comments

Comments
 (0)