@@ -162,9 +162,13 @@ def generate_response(response, event):
162162 return returndict
163163
164164
165- def get_path (path ):
166- if '?' in path :
167- path = path .split ('?' )[0 ]
165+ def strip_express_gateway_query_params (path ):
166+ """Contrary to regular AWS lambda HTTP events, Express Gateway
167+ (https://github.com/ExpressGateway/express-gateway-plugin-lambda)
168+ adds query parameters to the path, which we need to strip.
169+ """
170+ if "?" in path :
171+ path = path .split ("?" )[0 ]
168172 return path
169173
170174
@@ -197,7 +201,7 @@ def handle_payload_v1(app, event, context):
197201 # If a user is using a custom domain on API Gateway, they may have a base
198202 # path in their URL. This allows us to strip it out via an optional
199203 # environment variable.
200- path_info = get_path (event ["path" ])
204+ path_info = strip_express_gateway_query_params (event ["path" ])
201205 base_path = os .environ .get ("API_GATEWAY_BASE_PATH" )
202206 if base_path :
203207 script_name = "/" + base_path
@@ -249,7 +253,7 @@ def handle_payload_v2(app, event, context):
249253
250254 script_name = get_script_name (headers , event .get ("requestContext" , {}))
251255
252- path_info = get_path (event ["rawPath" ])
256+ path_info = strip_express_gateway_query_params (event ["rawPath" ])
253257
254258 body = event .get ("body" , "" )
255259 body = get_body_bytes (event , body )
@@ -300,7 +304,7 @@ def handle_lambda_integration(app, event, context):
300304
301305 script_name = get_script_name (headers , event )
302306
303- path_info = get_path (event ["requestPath" ])
307+ path_info = strip_express_gateway_query_params (event ["requestPath" ])
304308
305309 for key , value in event .get ("path" , {}).items ():
306310 path_info = path_info .replace ("{%s}" % key , value )
0 commit comments