A browser JavaScript library for getting and setting query parameters. Makes use of Window Location and pushState.
Include directly in the browser, or with a module bundler.
// bundler approach
var Qurl = require('@ryanburnette/qurl');
// or include the Js and Qurl will be an attribute of window
Create a new instance, accepts an optional queryString as a parameter to the constructor.
var url = new Qurl(/* queryString */);
// or
var url = Qurl(/* queryString */);
Get the query parameters as an object.
obj = url.query();
Get query parameters as a string
url.toString();
Get the value of a single query parameter by passing its key as an argument.
key = url.query('key');
Set the value for a query parameter.
url.query('key', 'value');
url.query('Robby', {
age: 20,
friends : ['Martin', 'Mole', 'Mindy'],
stuffs : [{ foo: 'bar' }, { gum: 'ball' }],
even : { deeper : down : [1,2,3] }
});
Delete a query parameter.
url.remove('key');
url.removeAll();
Toggle auto updating of URL history
url.updateHistory = true;