diff --git a/lib/helpers/combineURLs.js b/lib/helpers/combineURLs.js index bfd00e5284..f1b58a5864 100644 --- a/lib/helpers/combineURLs.js +++ b/lib/helpers/combineURLs.js @@ -8,8 +8,7 @@ * @returns {string} The combined URL */ module.exports = function combineURLs(baseURL, relativeURL) { - var end = relativeURL.replace(/^\/+/, ''); - return end - ? baseURL.replace(/\/+$/, '') + '/' + end + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL; }; diff --git a/test/specs/helpers/combineURLs.spec.js b/test/specs/helpers/combineURLs.spec.js index 4db0611ccb..2a427f5acd 100644 --- a/test/specs/helpers/combineURLs.spec.js +++ b/test/specs/helpers/combineURLs.spec.js @@ -16,4 +16,8 @@ describe('helpers::combineURLs', function () { it('should not insert slash when relative url missing/empty', function () { expect(combineURLs('https://api.github.com/users', '')).toBe('https://api.github.com/users'); }); + + it('should allow a single slash for relative url', function () { + expect(combineURLs('https://api.github.com/users', '/')).toBe('https://api.github.com/users/'); + }); });