url-join
Join urls and normalize as in path.join.
Last updated a year ago by jfromaniello .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install url-join 
SYNC missed versions from official npm registry.

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

Current Tags

  • 4.0.1                                ...           latest (a year ago)

12 Versions

  • 4.0.1                                ...           a year ago
  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 791
This Week 791
This Month 10,189
Last Day 727
Last Week 14,659
Last Month 61,929
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1295)

Copyright 2014 - 2016 © taobao.org |