|
1 | | -'use strict'; |
| 1 | +"use strict"; |
2 | 2 |
|
3 | | -import utils from '../utils.js'; |
| 3 | +import utils from "../utils.js"; |
4 | 4 | import AxiosHeaders from "./AxiosHeaders.js"; |
5 | 5 |
|
6 | | -const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing; |
| 6 | +const headersToObject = (thing) => |
| 7 | + thing instanceof AxiosHeaders ? { ...thing } : thing; |
7 | 8 |
|
8 | 9 | /** |
9 | 10 | * Config-specific merge-function which creates a new config-object |
@@ -92,14 +93,27 @@ export default function mergeConfig(config1, config2) { |
92 | 93 | socketPath: defaultToConfig2, |
93 | 94 | responseEncoding: defaultToConfig2, |
94 | 95 | validateStatus: mergeDirectKeys, |
95 | | - headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true) |
| 96 | + headers: (a, b, prop) => |
| 97 | + mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true), |
96 | 98 | }; |
97 | 99 |
|
98 | | - utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) { |
99 | | - const merge = mergeMap[prop] || mergeDeepProperties; |
100 | | - const configValue = merge(config1[prop], config2[prop], prop); |
101 | | - (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); |
102 | | - }); |
| 100 | + utils.forEach( |
| 101 | + Object.keys({ ...config1, ...config2 }), |
| 102 | + function computeConfigValue(prop) { |
| 103 | + if ( |
| 104 | + prop === "__proto__" || |
| 105 | + prop === "constructor" || |
| 106 | + prop === "prototype" |
| 107 | + ) |
| 108 | + return; |
| 109 | + const merge = utils.hasOwnProp(mergeMap, prop) |
| 110 | + ? mergeMap[prop] |
| 111 | + : mergeDeepProperties; |
| 112 | + const configValue = merge(config1[prop], config2[prop], prop); |
| 113 | + (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || |
| 114 | + (config[prop] = configValue); |
| 115 | + }, |
| 116 | + ); |
103 | 117 |
|
104 | 118 | return config; |
105 | 119 | } |
0 commit comments