diff --git a/lib/core/buildFullPath.js b/lib/core/buildFullPath.js index ba07b22..3050bd6 100644 --- a/lib/core/buildFullPath.js +++ b/lib/core/buildFullPath.js @@ -15,7 +15,7 @@ import combineURLs from '../helpers/combineURLs.js'; */ export default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) { let isRelativeUrl = !isAbsoluteURL(requestedURL); - if (baseURL && isRelativeUrl || allowAbsoluteUrls == false) { + if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) { return combineURLs(baseURL, requestedURL); } return requestedURL; diff --git a/test/specs/core/buildFullPath.spec.js b/test/specs/core/buildFullPath.spec.js index 2dfbe1b..19319cb 100644 --- a/test/specs/core/buildFullPath.spec.js +++ b/test/specs/core/buildFullPath.spec.js @@ -13,6 +13,10 @@ describe('helpers::buildFullPath', function () { expect(buildFullPath('https://api.github.com', 'https://api.example.com/users', false)).toBe('https://api.github.com/https://api.example.com/users'); }); + it('should not combine the URLs when the requestedURL is absolute, allowAbsoluteUrls is false, and the baseURL is not configured', function () { + expect(buildFullPath(undefined, 'https://api.example.com/users', false)).toBe('https://api.example.com/users'); + }); + it('should not combine URLs when the baseURL is not configured', function () { expect(buildFullPath(undefined, '/users')).toBe('/users'); });