Skip to content

Commit f10c2e0

Browse files
fix(buildFullPath): handle allowAbsoluteUrls: false without baseURL (#6833)
Co-authored-by: Jay <jasonsaayman@gmail.com>
1 parent 1e6632c commit f10c2e0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/core/buildFullPath.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import combineURLs from '../helpers/combineURLs.js';
1515
*/
1616
export default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
1717
let isRelativeUrl = !isAbsoluteURL(requestedURL);
18-
if (baseURL && isRelativeUrl || allowAbsoluteUrls == false) {
18+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
1919
return combineURLs(baseURL, requestedURL);
2020
}
2121
return requestedURL;

test/specs/core/buildFullPath.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ describe('helpers::buildFullPath', function () {
1313
expect(buildFullPath('https://api.github.com', 'https://api.example.com/users', false)).toBe('https://api.github.com/https://api.example.com/users');
1414
});
1515

16+
it('should not combine the URLs when the requestedURL is absolute, allowAbsoluteUrls is false, and the baseURL is not configured', function () {
17+
expect(buildFullPath(undefined, 'https://api.example.com/users', false)).toBe('https://api.example.com/users');
18+
});
19+
1620
it('should not combine URLs when the baseURL is not configured', function () {
1721
expect(buildFullPath(undefined, '/users')).toBe('/users');
1822
});

0 commit comments

Comments
 (0)