2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

fix(buildFullPath): handle allowAbsoluteUrls: false without baseURL (#6833)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Marc Hassan
2025-03-18 14:01:37 -04:00
committed by GitHub
parent 1e6632cd62
commit f10c2e0de7
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -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;
+4
View File
@@ -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');
});