Repository URL to install this package:
|
Version:
0.0.11-rc1 ▾
|
/**
* Join two parts of a url string together.
*
* @note: This utility is useful if you don't want to manage
* forward slashes (or the absence thereof) manually.
* @param {String} baseUrl
* @param {String} pathStr
* @returns {String}
*/
function buildUrl(baseUrl, pathStr) {
var base;
var path = '';
if (typeof baseUrl !== 'string') {
throw new TypeError('baseUrl param must be a string, got ' + typeof baseUrl);
}
base = baseUrl.replace(/\/+$/, '');
if (baseUrl && typeof pathStr === 'string') {
path = pathStr.replace(/^\/+/, '');
}
return [base, path].join('/');
}
module.exports = buildUrl;