2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Add combineURLs helper

This commit is contained in:
Nick Uraltsev
2015-11-21 17:41:02 -08:00
parent 4bbde9ae6c
commit e253b0ef3e
2 changed files with 27 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
'use strict';
/**
* Creates a new URL by combining the specified URLs
*
* @param {string} baseURL The base URL
* @param {string} relativeURL The relative URL
* @returns {string} The combined URL
*/
module.exports = function combineURLs(baseURL, relativeURL) {
return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '');
};