(config)
| 37 | ); |
| 38 | |
| 39 | function resolveConfig(config) { |
| 40 | const newConfig = mergeConfig({}, config); |
| 41 | |
| 42 | // Read only own properties to prevent prototype pollution gadgets |
| 43 | // (e.g. Object.prototype.baseURL = 'https://evil.com'). |
| 44 | const own = (key) => (utils.hasOwnProp(newConfig, key) ? newConfig[key] : undefined); |
| 45 | |
| 46 | const data = own('data'); |
| 47 | let withXSRFToken = own('withXSRFToken'); |
| 48 | const xsrfHeaderName = own('xsrfHeaderName'); |
| 49 | const xsrfCookieName = own('xsrfCookieName'); |
| 50 | let headers = own('headers'); |
| 51 | const auth = own('auth'); |
| 52 | const baseURL = own('baseURL'); |
| 53 | const allowAbsoluteUrls = own('allowAbsoluteUrls'); |
| 54 | const url = own('url'); |
| 55 | |
| 56 | newConfig.headers = headers = AxiosHeaders.from(headers); |
| 57 | |
| 58 | newConfig.url = buildURL( |
| 59 | buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig), |
| 60 | own('params'), |
| 61 | own('paramsSerializer') |
| 62 | ); |
| 63 | |
| 64 | // HTTP basic authentication |
| 65 | if (auth) { |
| 66 | const username = utils.getSafeProp(auth, 'username') || ''; |
| 67 | const password = utils.getSafeProp(auth, 'password') || ''; |
| 68 | |
| 69 | try { |
| 70 | headers.set( |
| 71 | 'Authorization', |
| 72 | 'Basic ' + btoa(username + ':' + (password ? encodeUTF8(password) : '')) |
| 73 | ); |
| 74 | } catch (e) { |
| 75 | throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | if (utils.isFormData(data)) { |
| 80 | if ( |
| 81 | platform.hasStandardBrowserEnv || |
| 82 | platform.hasStandardBrowserWebWorkerEnv || |
| 83 | utils.isReactNative(data) |
| 84 | ) { |
| 85 | headers.setContentType(undefined); // browser/web worker/RN handles it |
| 86 | } else if (utils.isFunction(data.getHeaders)) { |
| 87 | // Node.js FormData (like form-data package) |
| 88 | setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy')); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Add xsrf header |
| 93 | // This is only done if running in a standard browser environment. |
| 94 | // Specifically not if we're in a web worker, or react-native. |
| 95 | |
| 96 | if (platform.hasStandardBrowserEnv) { |
no test coverage detected