Add-ons using the techniques described in this document are considered a legacy technology in Firefox. Don't use these techniques to develop new add-ons. Use WebExtensions instead. If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions.
From Firefox 53 onwards, no new legacy add-ons will be accepted on addons.mozilla.org (AMO).
From Firefox 57 onwards, WebExtensions will be the only supported extension type, and Firefox will not load other types.
Even before Firefox 57, changes coming up in the Firefox platform will break many legacy extensions. These changes include multiprocess Firefox (e10s), sandboxing, and multiple content processes. Legacy extensions that are affected by these changes should migrate to WebExtensions if they can. See the "Compatibility Milestones" document for more.
A wiki page containing resources, migration paths, office hours, and more, is available to help developers transition to the new technologies.
Unstable
Utility functions for working with query strings.
Globals
Functions
stringify(fields, separator, assignment)
Serializes an object containing name:value
pairs into a query string:
querystring.stringify({ foo: 'bar', baz: 4 }); // => 'foo=bar&baz=4'
By default '&'
and'='
are used as separator and assignment characters, but you can override this using additional optional parameters:
querystring.stringify({ foo: 'bar', baz: 4 }, ';', ':'); // => 'foo:bar;baz:4'
Parameters
fields : object
The data to convert to a query string.
separator : string
The string to use as a separator between each name:value
pair. By default this is "&"
.
assignment : string
The string to use between each name
and its corresponding value
. By default this is "="
.
Returns
string : The query string.
parse(querystring, separator, assignment)
Parse a query string into an object containing name:value
pairs:
querystring.parse('foo=bar&baz=bla') // => { foo: 'bar', baz: 'bla' }
Optionally separator
and assignment
arguments may be passed to override default '&'
and '='
characters:
querystring.parse('foo:bar
|baz:bla', '|', ':') // => { foo: 'bar', baz: 'bla' }
Parameters
querystring : string
The query string.
separator : string
The string to use as a separator between each name:value
pair. By default this is "&"
.
assignment : string
The string to use between each name
and its corresponding value
. By default this is "="
.
Returns
object : An object containing the components of the query string as name : value
pairs.
escape(query)
The escape function used by stringify
to encodes a string safely matching RFC 3986 for application/x-www-form-urlencoded
.
Parameters
query : string
The query string to escape.
Returns
string : The escaped query string.
unescape(query)
The unescape function used by parse
to decode a string safely.
Parameters
query : string
An escaped query string.
Returns
string : The unescaped string.