Skip to main content

http.urldecode(URLdataString)

Parses a string containing URL-encoded key-value pairs

Availability

Agent

Parameters

Name Type Description
URLdataString String The URL-encoded string you wish to decode

Returns

Table — the URL-encoded data as key-value pairs

Description

This method performs URL decoding, as defined in the RFC3986 specification, sections 2.1 to 2.3. The string can contain multiple fields, and so the result type is a Squirrel table of key-value pairs.

Both the key and the value will be strings, except when there are duplicate field-names in the URL-encoded string. In this case, the value will instead be a Squirrel array containing all the values assigned to the key. For more guidance, see the examples below. Squirrel code can check for the presence of array variables using code such as:

if (typeof(zootle.wurdle) == "array") { ... }

The http.urldecode() method is useful when processing query strings in HTTP requests, but see http.onrequest() for an instance of when the agent performs this processing automatically for query strings in the URL itself.

The corresponding encoding operation is http.urlencode().