Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.Normalize query string parameters in a CloudFront Functions viewer request
The following code example shows how to normalize query string parameters in a CloudFront Functions viewer request.
- JavaScript
-
- JavaScript runtime 2.0 for CloudFront Functions
-
function handler(event) {
var qs=[];
for (var key in event.request.querystring) {
if (event.request.querystring[key].multiValue) {
event.request.querystring[key].multiValue.forEach((mv) => {qs.push(key + "=" + mv.value)});
} else {
qs.push(key + "=" + event.request.querystring[key].value);
}
};
event.request.querystring = qs.sort().join('&');
return event.request;
}
For a complete list of AWS SDK developer guides and code examples, see
Using CloudFront with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.