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

Fixing combineURLs to support an empty relativeURL (#581)

* Fixing combineURLs to support an empty relativeURL

When combining the base and relative URLs, we should forego force
appending a slash to the base when the relative URL is empty.
This leads to a semantic url.

* Fixing combineURLs, allowing single slash relatives
This commit is contained in:
Lochlan Bunn
2016-12-08 15:23:45 +10:00
committed by Nick Uraltsev
parent cfe33d4fd3
commit fe7d09bb08
2 changed files with 11 additions and 1 deletions
+3 -1
View File
@@ -8,5 +8,7 @@
* @returns {string} The combined URL
*/
module.exports = function combineURLs(baseURL, relativeURL) {
return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '');
return relativeURL
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
: baseURL;
};