url.query

This function returns the encoded query string if second parameter is set to true. It returns an object with a key value pair of query and value, if the second parameter is set to false.

Syntax

url.query(rawURLString, encode)

Arguments

Argument

Type

Description

rawURLString

string

Raw URL string

encode

boolean

Set this argument to true to encode the query string. Set it to false to get the object.

Returns

Type

Description

Any

The encoded query string or object

Examples

The function url.query("https://example.com:8080/root-path/sub-path?query=example+query+%2F+question#fragment", true) returns "query=example+query+%2F+question".