Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Qurl

repo npm

A browser JavaScript library for getting and setting query parameters. Makes use of Window Location and pushState.

Usage

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;

About

A JavaScript library for getting and setting query parameters.

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •