Skip to content

Commit 4203d4a

Browse files
author
Michael Brewer
committed
chore: maybe use lstrip?
1 parent 286b0de commit 4203d4a

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Diff for: aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,18 @@ def __init__(
2828
self.api_id = api_id
2929
self.stage = stage
3030
self.http_method = http_method
31-
self.resource = resource
31+
# Remove matching "/" from `resource`.
32+
self.resource = resource.lstrip("/")
3233

3334
@property
3435
def arn(self) -> str:
3536
"""Build an arn from its parts
3637
eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
3738
return (
3839
f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}/"
39-
f"{self.http_method}/{self._resource}"
40+
f"{self.http_method}/{self.resource}"
4041
)
4142

42-
@property
43-
def _resource(self) -> str:
44-
"""Remove matching "/" from `resource`. To be replaced with built-in `removeprefix`"""
45-
if self.resource.startswith("/"):
46-
return self.resource[1:]
47-
return self.resource
48-
4943

5044
def parse_api_gateway_arn(arn: str) -> APIGatewayRouteArn:
5145
"""Parses a gateway route arn as a APIGatewayRouteArn class

0 commit comments

Comments
 (0)