Join urls and normalize as in path.join.
npm install @xtuc/url-joinJoin all arguments together and normalize the resulting url.
~~~
npm install url-join
~~~
~~~javascript
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'
~~~
It also works in the browser, you can either include ``lib/url-join.js`` in your page:
~~~html
~~~
Or using an AMD module system like requirejs:
~~~javascript
define(['path/url-join.js'], function (urljoin) {
urljoin('http://blabla.com', 'foo?a=1');
});
~~~
MIT