Skip to content

Commit 6a73c14

Browse files
committed
refactor: minor optimization
1 parent 046c731 commit 6a73c14

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/stac_auth_proxy/middleware/AuthenticationExtensionMiddleware.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ def should_transform_response(
4444
"""Determine if the response should be transformed."""
4545
# Match STAC catalog, collection, or item URLs with a single regex
4646
return all(
47-
[
48-
re.match(
47+
re.match(expr, val)
48+
for expr, val in [
49+
(
4950
# catalog, collections, collection, items, item, search
5051
r"^(/|/collections(/[^/]+(/items(/[^/]+)?)?)?|/search)$",
5152
request.url.path,
5253
),
53-
re.match(
54+
(
5455
self.json_content_type_expr,
5556
response_headers.get("content-type", ""),
5657
),

src/stac_auth_proxy/middleware/UpdateOpenApiMiddleware.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ def should_transform_response(
3232
) -> bool:
3333
"""Only transform responses for the OpenAPI spec path."""
3434
return all(
35-
[
36-
re.match(self.openapi_spec_path, request.url.path),
37-
re.match(
35+
re.match(expr, val)
36+
for expr, val in [
37+
(self.openapi_spec_path, request.url.path),
38+
(
3839
self.json_content_type_expr,
3940
response_headers.get("content-type", ""),
4041
),

0 commit comments

Comments
 (0)