Skip to content

Commit

Permalink
fix problem with package.json exports declaration for CommonJS
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Oct 14, 2022
1 parent ef1c48a commit 8f2eb5d
Show file tree
Hide file tree
Showing 13 changed files with 594 additions and 799 deletions.
691 changes: 214 additions & 477 deletions dist/axios.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.min.js.map

Large diffs are not rendered by default.

41 changes: 25 additions & 16 deletions dist/esm/axios.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/esm/axios.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/axios.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/axios.min.js.map

Large diffs are not rendered by default.

50 changes: 30 additions & 20 deletions dist/node/axios.cjs
Expand Up @@ -1049,12 +1049,20 @@ function buildURL(url, params, options) {

const _encode = options && options.encode || encode;

const serializerParams = utils.isURLSearchParams(params) ?
params.toString() :
new AxiosURLSearchParams(params, options).toString(_encode);
const serializeFn = options && options.serialize;

if (serializerParams) {
url += (url.indexOf('?') === -1 ? '?' : '&') + serializerParams;
let serializedParams;

if (serializeFn) {
serializedParams = serializeFn(params, options);
} else {
serializedParams = utils.isURLSearchParams(params) ?
params.toString() :
new AxiosURLSearchParams(params, options).toString(_encode);
}

if (serializedParams) {
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}

return url;
Expand Down Expand Up @@ -1451,7 +1459,7 @@ function normalizeValue(value) {
return value;
}

return String(value);
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
}

function parseTokens(str) {
Expand Down Expand Up @@ -1538,13 +1546,7 @@ Object.assign(AxiosHeaders.prototype, {
return;
}

if (utils.isArray(_value)) {
_value = _value.map(normalizeValue);
} else {
_value = normalizeValue(_value);
}

self[key || _header] = _value;
self[key || _header] = normalizeValue(_value);
}

if (utils.isPlainObject(header)) {
Expand Down Expand Up @@ -1658,13 +1660,13 @@ Object.assign(AxiosHeaders.prototype, {
return this;
},

toJSON: function() {
toJSON: function(asStrings) {
const obj = Object.create(null);

utils.forEach(Object.assign({}, this[$defaults] || null, this),
(value, header) => {
if (value == null || value === false) return;
obj[header] = utils.isArray(value) ? value.join(', ') : value;
obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
});

return obj;
Expand Down Expand Up @@ -2003,7 +2005,7 @@ function dispatchBeforeRedirect(options) {
* If the proxy or config afterRedirects functions are defined, call them with the options
*
* @param {http.ClientRequestArgs} options
* @param {AxiosProxyConfig} configProxy
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
* @param {string} location
*
* @returns {http.ClientRequestArgs}
Expand Down Expand Up @@ -2034,13 +2036,14 @@ function setProxy(options, configProxy, location) {
}

options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
options.hostname = proxy.hostname;
const proxyHost = proxy.hostname || proxy.host;
options.hostname = proxyHost;
// Replace 'host' since options is not a URL object
options.host = proxy.hostname;
options.host = proxyHost;
options.port = proxy.port;
options.path = location;
if (proxy.protocol) {
options.protocol = proxy.protocol;
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
}
}

Expand Down Expand Up @@ -3401,7 +3404,7 @@ class Axios {

config = mergeConfig(this.defaults, config);

const transitional = config.transitional;
const {transitional, paramsSerializer} = config;

if (transitional !== undefined) {
validator.assertOptions(transitional, {
Expand All @@ -3411,6 +3414,13 @@ class Axios {
}, false);
}

if (paramsSerializer !== undefined) {
validator.assertOptions(paramsSerializer, {
encode: validators.function,
serialize: validators.function
}, true);
}

// Set config.method
config.method = (config.method || this.defaults.method || 'get').toLowerCase();

Expand Down
2 changes: 1 addition & 1 deletion dist/node/axios.cjs.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -28,5 +28,6 @@ export {
Cancel,
isAxiosError,
spread,
toFormData
toFormData,
axios
}

0 comments on commit 8f2eb5d

Please sign in to comment.