Skip to content
Javascript URL Builder and Manipulator
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
libs Initial files and libraries Sep 28, 2012
tests #3: Parse and set hash parameters Oct 5, 2012
LICENSE Updated License year and owner Aug 19, 2014 Updated documentation Oct 5, 2012
jurl.js Update jurl.js Jan 12, 2017
jurl.min.js Corrected issue when there is no host name Jan 12, 2017


Javascript URL Builder and Manipulator


A simple utility to parse urls and allow you to manipulate and rebuild them.


addUrlParameter(key, index): Allows you add a new URL parameter to the URL. The new key is appened at the end of the URL. The index parameter is optional. If you provide it then the URL parameter will be positioned at exactly that index rather than appended at the end.

setQueryParameter(key, value): Allows you to add a new query parameter in the query string of the URL. Takes in a key and a value (the value is optional). If a key already exists then it replaces its value with the new one.

setHashParameter(hash): Sets the hash part of the URL to whatever you give it. If nothing is given then the hash becomes empty.

getQueryParameter(key): Gets the value of a query parameter based on a given key.

getParameterIndex(key): Gets the index of a given key based on where it is positioned in the URL parameters

removeUrlParameter(key): Removes the URL parameters with the given key.

removeQueryParameter(key): Removes the query parameter with the given key.

build(): Builds the URL into a complete URL string.


Parsing a URL

new jurl("").build();

Adding URL parameter

new jurl("").addUrlParameter("foo").build();

Adding URL parameter at index

new jurl("").addUrlParameter("foo", 1).build();

Setting a query parameter

new jurl("").setQueryParameter("foo", "bar").build();

Setting hash parameter

new jurl("").setHashParameter("foo").build();

Getting query parameter value

new jurl("").getQueryParameter("foo");	


Getting URL parameter index

new jurl("").getParameterIndex("foo");	


Removing a URL parameter

new jurl("").removeUrlParameter("foo").build();

Removing a query parameter

new jurl("").removeQueryParameter("foo").build();

Chaining all

new jurl("")
	.setQueryParameter("baz", "bar")

You can’t perform that action at this time.