Skip to content

Commit

Permalink
Simplify query string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
RioKnightleyNHS committed Oct 23, 2024
1 parent 62bda59 commit 2590222
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lambdas/handlers/edge_presign_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import json
import logging
from urllib.parse import parse_qs

from enums.lambda_error import LambdaError
from services.edge_presign_service import EdgePresignService
Expand Down Expand Up @@ -46,10 +47,7 @@ def lambda_handler(event, context):
raise CloudFrontEdgeException(500, LambdaError.EdgeNoOrigin)

try:
query_params = {
k: v
for k, v in (x.split("=") for x in querystring.split("&") if "=" in x)
}
query_params = {k: v[0] for k, v in parse_qs(querystring).items()}
except ValueError:
logger.error(f"Malformed query string: {querystring}")
raise CloudFrontEdgeException(500, LambdaError.EdgeMalformedQuery)
Expand Down

0 comments on commit 2590222

Please sign in to comment.