This repository has been archived on 2025-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
inkletblot-com-v1/node_modules/url-join
2019-12-02 12:10:45 +10:30
..
lib initial commit 2019-12-02 12:10:45 +10:30
test initial commit 2019-12-02 12:10:45 +10:30
.npmignore initial commit 2019-12-02 12:10:45 +10:30
.travis.yml initial commit 2019-12-02 12:10:45 +10:30
bower.json initial commit 2019-12-02 12:10:45 +10:30
LICENSE initial commit 2019-12-02 12:10:45 +10:30
package.json initial commit 2019-12-02 12:10:45 +10:30
README.md initial commit 2019-12-02 12:10:45 +10:30

Join all arguments together and normalize the resulting url.

Install

npm install url-join

Usage

var urljoin = require('url-join');

var fullUrl = urljoin('http://www.google.com', 'a', '/b/cd', '?foo=123');

console.log(fullUrl);

Prints:

'http://www.google.com/a/b/cd?foo=123'

Browser and AMD

It also works in the browser, you can either include lib/url-join.js in your page:

<script src="url-join.js"></script>
<script type="text/javascript">
	urljoin('http://blabla.com', 'foo?a=1')
</script>

Or using an AMD module system like requirejs:

define(['path/url-join.js'], function (urljoin) {
  urljoin('http://blabla.com', 'foo?a=1');
});

License

MIT