Skip to content

Commit 625fc51

Browse files
committed
fix(apigw): route regression for non-word chars 1st take
1 parent a768b68 commit 625fc51

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
logger = logging.getLogger(__name__)
2222

2323
_DYNAMIC_ROUTE_PATTERN = r"(<\w+>)"
24-
_NAMED_GROUP_BOUNDARY_PATTERN = r"(?P\1\\w+\\b)"
24+
_NAMED_GROUP_BOUNDARY_PATTERN = r"(?P\1[-%@.:\\w]+)"
2525

2626

2727
class ProxyEventType(Enum):

tests/functional/event_handler/test_api_gateway.py

+16
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,19 @@ def get_network_account(account_id: str, network_id: str):
701701
event["resource"] = "/accounts/{account_id}/source_networks/{network_id}"
702702
event["path"] = "/accounts/nested_account/source_networks/network"
703703
app.resolve(event, {})
704+
705+
706+
def test_non_word_chars_route():
707+
# GIVEN
708+
app = ApiGatewayResolver()
709+
event = deepcopy(LOAD_GW_EVENT)
710+
711+
# WHEN
712+
@app.get("/accounts/<account_id>")
713+
def get_account(account_id: str):
714+
assert account_id == "12345"
715+
716+
# THEN
717+
event["resource"] = "/accounts/{account_id}"
718+
event["path"] = "/accounts/12345"
719+
app.resolve(event, None)

0 commit comments

Comments
 (0)