mirror of
https://github.com/axios/axios.git
synced 2026-04-12 14:41:55 +08:00
* Adding tests to show config.url mutation Because config.url is modified while processing the request when the baseURL is set, it is impossible to perform a retry with the provided config object. Ref #1628 * Fixing url combining without modifying config.url As config.url is not modified anymore during the request processing. The request can safely be retried after it failed with the provided config. resolves #1628
21 lines
695 B
JavaScript
21 lines
695 B
JavaScript
'use strict';
|
|
|
|
var isAbsoluteURL = require('../helpers/isAbsoluteURL');
|
|
var combineURLs = require('../helpers/combineURLs');
|
|
|
|
/**
|
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
* only when the requestedURL is not already an absolute URL.
|
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
*
|
|
* @param {string} baseURL The base URL
|
|
* @param {string} requestedURL Absolute or relative URL to combine
|
|
* @returns {string} The combined full path
|
|
*/
|
|
module.exports = function buildFullPath(baseURL, requestedURL) {
|
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
return combineURLs(baseURL, requestedURL);
|
|
}
|
|
return requestedURL;
|
|
};
|