Function: urlJoin

urlJoin(...args): string

URLJoin

Parameters

Name Type Description
...args string[] URL segments to join

Returns

string

  • The joined and normalized URL

Description

Joins all given URL segments together, then normalizes the resulting URL.

Use String.prototype.join('/') to combine URL segments, then a series of String.prototype.replace() calls with various regexps to normalize the resulting URL (remove double slashes, add proper slashes for protocol, remove slashes before parameters, combine parameters with '&' and normalize first parameter delimiter).

Example

URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo');
// => 'http://www.google.com/a/b/cd?foo=123&bar=foo'
ON THIS PAGE