querystring.clean

STRINGquerystring.cleanSTRINGurl

Available inall subroutines.

Returns the given URL without empty parameters. Parameters are considered empty when their names are empty. Effectively, this strips a malformed query string of superfluous separators, such as a trailing ? or extra ampersands:

  • /path?name=value&&=value-only&name-only becomes /path?name=value&name-only
  • /path? becomes /path

Example

set req.url = querystring.clean(req.url);

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)