mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
* fix: prevent request url override prevent request URL from overriding preconfigured base URL BREAKING CHANGE: code relying on the above will now combine the URLs instead of prefer request URL * feat: add config option for allowing absolute URLs * fix: add default value for allowAbsoluteUrls in buildFullPath * fix: typo in flow control when setting allowAbsoluteUrls * feat: update tests supporting issue #5902 functionality * feat: update README.md with allowAbsoluteUrls * fix: properly group conditions in buildFullPath.js to avoid undefined error when baseUrl undefined * Update README.md fix typo * fix: update build full path logic to address failing test case * fix: update base URL test * fix: remove problem test (works locally, will not work in the pipeline) * fix: update https test to use github.com instead of google.com * fix: revert previous commit * fix: add back problem test * chore: remove un-needed passed var to URL class instanciation --------- Co-authored-by: Austin Ryan Lawson <ryan.lawson2@gmail.com> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+10
-1
@@ -97,6 +97,15 @@ class Axios {
|
||||
}
|
||||
}
|
||||
|
||||
// Set config.allowAbsoluteUrls
|
||||
if (config.allowAbsoluteUrls !== undefined) {
|
||||
// do nothing
|
||||
} else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
||||
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
||||
} else {
|
||||
config.allowAbsoluteUrls = true;
|
||||
}
|
||||
|
||||
validator.assertOptions(config, {
|
||||
baseUrl: validators.spelling('baseURL'),
|
||||
withXsrfToken: validators.spelling('withXSRFToken')
|
||||
@@ -192,7 +201,7 @@ class Axios {
|
||||
|
||||
getUri(config) {
|
||||
config = mergeConfig(this.defaults, config);
|
||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
||||
return buildURL(fullPath, config.params, config.paramsSerializer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ import combineURLs from '../helpers/combineURLs.js';
|
||||
*
|
||||
* @returns {string} The combined full path
|
||||
*/
|
||||
export default function buildFullPath(baseURL, requestedURL) {
|
||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||
export default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
||||
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
||||
if (baseURL && isRelativeUrl || allowAbsoluteUrls == false) {
|
||||
return combineURLs(baseURL, requestedURL);
|
||||
}
|
||||
return requestedURL;
|
||||
|
||||
Reference in New Issue
Block a user