Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple JavaScript library to make it easier to deal with URLs
tree: aa964a6ac6

README.md

URLUtils JavaScript Library

URLUtils is a simple, lightweight library that makes it easier to perform some common URL-related tasks in JavaScript.

URLUtils.getParam(name)

name - The name of the URL parameter of which the value should be returned.

Returns a string, or false if a parameter matching name is not found in the page URL.

URLUtils.getParams()

Returns an object containing the name-value pairs of all parameters found in the page URL. Returns an empty object if no parameters are found in the URL.

URLUtils.getHash()

Returns a string containing the string following the # character in the URL. If no # character is found an empty string is returned.

URLUtils.makeSlug(str)

str - A string to be converted into a URL friendly "slug".

Returns a string containing a URL friendly "slug" of the argument. The input is converted to lower case, special characters are removed and spaces are replaced by hypens. For example, the input string "Quick & Easy" would become "quick-easy".

URLUtils.makeQueryString(obj, includeUndefined)

obj - An object to create a query string from. includeUndefined - Boolean value to specify whether undefined values should be included in the query string.

Returns a string in the format of a URL query string (key=value&key2=value2). Nested objects are flattened so properties of nested objects will appear in the string as if they were properties of obj. If includeUndefined is true, properties whose value is undefined will appear in the string with a value of undefined: key=undefined&key2=value. If includeUndefined is false, such properties will appear as the empty string: key=&key2=value.

Something went wrong with that request. Please try again.