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:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user