Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
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 Amazon SDK developer guides and code examples, see
Using CloudFront with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.