JavaScript URL manipulation library

URL.js is a small but awesome JavaScript URL library for working with URLs. It provides a jQuery style API (meaning that it has a fluent interface, method chaining) to read and write all regular components and number of convenience methods including .directory() or .authority().

This JavaScript URL library offers a simple but yet powerful way of working with query strings, provides a number of URI-normalization functions and can convert relative/absolute paths. To understand this better, look at the example provided bellow.

URI("?hello=world")
    .addSearch("hello", "mars")
        // -> ?hello=world&hello=mars
    .addSearch({ foo: ["bar", "baz"] })
        // -> ?hello=world&hello=mars&foo=bar&foo=baz
    .removeSearch("hello", "mars")
        // -> ?hello=world&foo=bar&foo=baz
    .removeSearch("foo")
        // -> ?hello=world

JavaScript URI library

JavaScript URL manipulation library

Download URL.js

Related Posts

Let users find links on your page by typing

Easy handle keyboard shortcuts with JavaScript

JavaScript Notifications For Bootstrap Or jQuery UI

JavaScript framework similar to CoffeScript

Leave a Reply