If I have a defaultKey such as index.html, and I request a / route with a query string, e.g., /?foo=bar. If i do this, that first if statement thats supposed to replace "" with defaultKey, s3Key will be ?foo=bar and my defaultKey will not be used. The code continues and removes the query string from the s3Key making it s3Key = "". If my s3Key is passed to the s3Params as a blank string, which is passed to s3Request and finally when we call s3Request.createReadStream(), a 500 error is thrown by aws param_validator: UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Key. \n\n this fix removes the query string first since there is really nouse for it, to have the if that replaces "/" with defaultKey will work even if there is a query string.
If I have a defaultKey such as index.html, and I request a / route with a query string, e.g., /?foo=bar. If i do this, that first if statement thats supposed to replace "" with defaultKey, s3Key will be ?foo=bar and my defaultKey will not be used. The code continues and removes the query string from the s3Key making it s3Key = "". If my s3Key is passed to the s3Params as a blank string, which is passed to s3Request and finally when we call s3Request.createReadStream(), a 500 error is thrown by aws param_validator: UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Key. \n\n this fix removes the query string first since there is really nouse for it, to have the if that replaces "/" with defaultKey will work even if there is a query string.