...**/!(*.map|*.min.js)Size
Gzip
Dependencies
Publish
Install
Size
Gzip
Dependencies
Publish
Install
@@ -1,4 +1,4 @@ | ||
| 1 | /*! Axios v1.14.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 1 | /*! Axios v1.15.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 2 | 2 | 'use strict'; |
| 3 | 3 | |
| 4 | 4 | /** |
@@ -1852,18 +1852,49 @@ | ||
| 1852 | 1852 | |
| 1853 | 1853 | const $internals = Symbol('internals'); |
| 1854 | 1854 | |
| 1855 | const isValidHeaderValue = (value) => !/[\r\n]/.test(value); | |
| 1856 | ||
| 1857 | function assertValidHeaderValue(value, header) { | |
| 1858 | if (value === false || value == null) { | |
| 1859 | return; | |
| 1860 | } | |
| 1861 | ||
| 1862 | if (utils$1.isArray(value)) { | |
| 1863 | value.forEach((v) => assertValidHeaderValue(v, header)); | |
| 1864 | return; | |
| 1865 | } | |
| 1866 | ||
| 1867 | if (!isValidHeaderValue(String(value))) { | |
| 1868 | throw new Error(`Invalid character in header content ["${header}"]`); | |
| 1869 | } | |
| 1870 | } | |
| 1871 | ||
| 1855 | 1872 | function normalizeHeader(header) { |
| 1856 | 1873 | return header && String(header).trim().toLowerCase(); |
| 1857 | 1874 | } |
| 1858 | 1875 | |
| 1876 | function stripTrailingCRLF(str) { | |
| 1877 | let end = str.length; | |
| 1878 | ||
| 1879 | while (end > 0) { | |
| 1880 | const charCode = str.charCodeAt(end - 1); | |
| 1881 | ||
| 1882 | if (charCode !== 10 && charCode !== 13) { | |
| 1883 | break; | |
| 1884 | } | |
| 1885 | ||
| 1886 | end -= 1; | |
| 1887 | } | |
| 1888 | ||
| 1889 | return end === str.length ? str : str.slice(0, end); | |
| 1890 | } | |
| 1891 | ||
| 1859 | 1892 | function normalizeValue(value) { |
| 1860 | 1893 | if (value === false || value == null) { |
| 1861 | 1894 | return value; |
| 1862 | 1895 | } |
| 1863 | 1896 | |
| 1864 | return utils$1.isArray(value) | |
| 1865 | ? value.map(normalizeValue) | |
| 1866 | : String(value).replace(/[\r\n]+$/, ''); | |
| 1897 | return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value)); | |
| 1867 | 1898 | } |
| 1868 | 1899 | |
| 1869 | 1900 | function parseTokens(str) { |
@@ -1945,6 +1976,7 @@ | ||
| 1945 | 1976 | _rewrite === true || |
| 1946 | 1977 | (_rewrite === undefined && self[key] !== false) |
| 1947 | 1978 | ) { |
| 1979 | assertValidHeaderValue(_value, _header); | |
| 1948 | 1980 | self[key || _header] = normalizeValue(_value); |
| 1949 | 1981 | } |
| 1950 | 1982 | } |
@@ -3556,7 +3588,7 @@ | ||
| 3556 | 3588 | ); |
| 3557 | 3589 | } |
| 3558 | 3590 | |
| 3559 | const VERSION = "1.14.0"; | |
| 3591 | const VERSION = "1.15.0"; | |
| 3560 | 3592 | |
| 3561 | 3593 | const validators$1 = {}; |
| 3562 | 3594 | |
@@ -3700,13 +3732,29 @@ | ||
| 3700 | 3732 | Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error()); |
| 3701 | 3733 | |
| 3702 | 3734 | // slice off the Error: ... line |
| 3703 | const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : ''; | |
| 3735 | const stack = (() => { | |
| 3736 | if (!dummy.stack) { | |
| 3737 | return ''; | |
| 3738 | } | |
| 3739 | ||
| 3740 | const firstNewlineIndex = dummy.stack.indexOf('\n'); | |
| 3741 | ||
| 3742 | return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1); | |
| 3743 | })(); | |
| 3704 | 3744 | try { |
| 3705 | 3745 | if (!err.stack) { |
| 3706 | 3746 | err.stack = stack; |
| 3707 | 3747 | // match without the 2 top stack lines |
| 3708 | } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) { | |
| 3709 | err.stack += '\n' + stack; | |
| 3748 | } else if (stack) { | |
| 3749 | const firstNewlineIndex = stack.indexOf('\n'); | |
| 3750 | const secondNewlineIndex = | |
| 3751 | firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1); | |
| 3752 | const stackWithoutTwoTopLines = | |
| 3753 | secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1); | |
| 3754 | ||
| 3755 | if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) { | |
| 3756 | err.stack += '\n' + stack; | |
| 3757 | } | |
| 3710 | 3758 | } |
| 3711 | 3759 | } catch (e) { |
| 3712 | 3760 | // ignore the case where "stack" is an un-writable property |
@@ -1,4 +1,4 @@ | ||
| 1 | /*! Axios v1.14.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 1 | /*! Axios v1.15.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 2 | 2 | (function (global, factory) { |
| 3 | 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 4 | 4 | typeof define === 'function' && define.amd ? define(factory) : |
@@ -2196,14 +2196,42 @@ | ||
| 2196 | 2196 | }); |
| 2197 | 2197 | |
| 2198 | 2198 | var $internals = Symbol('internals'); |
| 2199 | var isValidHeaderValue = function isValidHeaderValue(value) { | |
| 2200 | return !/[\r\n]/.test(value); | |
| 2201 | }; | |
| 2202 | function assertValidHeaderValue(value, header) { | |
| 2203 | if (value === false || value == null) { | |
| 2204 | return; | |
| 2205 | } | |
| 2206 | if (utils$1.isArray(value)) { | |
| 2207 | value.forEach(function (v) { | |
| 2208 | return assertValidHeaderValue(v, header); | |
| 2209 | }); | |
| 2210 | return; | |
| 2211 | } | |
| 2212 | if (!isValidHeaderValue(String(value))) { | |
| 2213 | throw new Error("Invalid character in header content [\"".concat(header, "\"]")); | |
| 2214 | } | |
| 2215 | } | |
| 2199 | 2216 | function normalizeHeader(header) { |
| 2200 | 2217 | return header && String(header).trim().toLowerCase(); |
| 2201 | 2218 | } |
| 2219 | function stripTrailingCRLF(str) { | |
| 2220 | var end = str.length; | |
| 2221 | while (end > 0) { | |
| 2222 | var charCode = str.charCodeAt(end - 1); | |
| 2223 | if (charCode !== 10 && charCode !== 13) { | |
| 2224 | break; | |
| 2225 | } | |
| 2226 | end -= 1; | |
| 2227 | } | |
| 2228 | return end === str.length ? str : str.slice(0, end); | |
| 2229 | } | |
| 2202 | 2230 | function normalizeValue(value) { |
| 2203 | 2231 | if (value === false || value == null) { |
| 2204 | 2232 | return value; |
| 2205 | 2233 | } |
| 2206 | return utils$1.isArray(value) ? value.map(normalizeValue) : String(value).replace(/[\r\n]+$/, ''); | |
| 2234 | return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value)); | |
| 2207 | 2235 | } |
| 2208 | 2236 | function parseTokens(str) { |
| 2209 | 2237 | var tokens = Object.create(null); |
@@ -2264,6 +2292,7 @@ | ||
| 2264 | 2292 | } |
| 2265 | 2293 | var key = utils$1.findKey(self, lHeader); |
| 2266 | 2294 | if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) { |
| 2295 | assertValidHeaderValue(_value, _header); | |
| 2267 | 2296 | self[key || _header] = normalizeValue(_value); |
| 2268 | 2297 | } |
| 2269 | 2298 | } |
@@ -3831,7 +3860,7 @@ | ||
| 3831 | 3860 | }); |
| 3832 | 3861 | } |
| 3833 | 3862 | |
| 3834 | var VERSION = "1.14.0"; | |
| 3863 | var VERSION = "1.15.0"; | |
| 3835 | 3864 | |
| 3836 | 3865 | var validators$1 = {}; |
| 3837 | 3866 | |
@@ -3946,7 +3975,7 @@ | ||
| 3946 | 3975 | key: "request", |
| 3947 | 3976 | value: (function () { |
| 3948 | 3977 | var _request2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configOrUrl, config) { |
| 3949 | var dummy, stack, _t; | |
| 3978 | var dummy, stack, firstNewlineIndex, secondNewlineIndex, stackWithoutTwoTopLines, _t; | |
| 3950 | 3979 | return _regenerator().w(function (_context) { |
| 3951 | 3980 | while (1) switch (_context.p = _context.n) { |
| 3952 | 3981 | case 0: |
@@ -3963,13 +3992,24 @@ | ||
| 3963 | 3992 | Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error(); |
| 3964 | 3993 | |
| 3965 | 3994 | // slice off the Error: ... line |
| 3966 | stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : ''; | |
| 3995 | stack = function () { | |
| 3996 | if (!dummy.stack) { | |
| 3997 | return ''; | |
| 3998 | } | |
| 3999 | var firstNewlineIndex = dummy.stack.indexOf('\n'); | |
| 4000 | return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1); | |
| 4001 | }(); | |
| 3967 | 4002 | try { |
| 3968 | 4003 | if (!_t.stack) { |
| 3969 | 4004 | _t.stack = stack; |
| 3970 | 4005 | // match without the 2 top stack lines |
| 3971 | } else if (stack && !String(_t.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) { | |
| 3972 | _t.stack += '\n' + stack; | |
| 4006 | } else if (stack) { | |
| 4007 | firstNewlineIndex = stack.indexOf('\n'); | |
| 4008 | secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1); | |
| 4009 | stackWithoutTwoTopLines = secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1); | |
| 4010 | if (!String(_t.stack).endsWith(stackWithoutTwoTopLines)) { | |
| 4011 | _t.stack += '\n' + stack; | |
| 4012 | } | |
| 3973 | 4013 | } |
| 3974 | 4014 | } catch (e) { |
| 3975 | 4015 | // ignore the case where "stack" is an un-writable property |
@@ -1,4 +1,4 @@ | ||
| 1 | /*! Axios v1.14.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 1 | /*! Axios v1.15.0 Copyright (c) 2026 Matt Zabriskie and contributors */ | |
| 2 | 2 | /** |
| 3 | 3 | * Create a bound version of a function with a specified `this` context |
| 4 | 4 | * |
@@ -1850,18 +1850,49 @@ | ||
| 1850 | 1850 | |
| 1851 | 1851 | const $internals = Symbol('internals'); |
| 1852 | 1852 | |
| 1853 | const isValidHeaderValue = (value) => !/[\r\n]/.test(value); | |
| 1854 | ||
| 1855 | function assertValidHeaderValue(value, header) { | |
| 1856 | if (value === false || value == null) { | |
| 1857 | return; | |
| 1858 | } | |
| 1859 | ||
| 1860 | if (utils$1.isArray(value)) { | |
| 1861 | value.forEach((v) => assertValidHeaderValue(v, header)); | |
| 1862 | return; | |
| 1863 | } | |
| 1864 | ||
| 1865 | if (!isValidHeaderValue(String(value))) { | |
| 1866 | throw new Error(`Invalid character in header content ["${header}"]`); | |
| 1867 | } | |
| 1868 | } | |
| 1869 | ||
| 1853 | 1870 | function normalizeHeader(header) { |
| 1854 | 1871 | return header && String(header).trim().toLowerCase(); |
| 1855 | 1872 | } |
| 1856 | 1873 | |
| 1874 | function stripTrailingCRLF(str) { | |
| 1875 | let end = str.length; | |
| 1876 | ||
| 1877 | while (end > 0) { | |
| 1878 | const charCode = str.charCodeAt(end - 1); | |
| 1879 | ||
| 1880 | if (charCode !== 10 && charCode !== 13) { | |
| 1881 | break; | |
| 1882 | } | |
| 1883 | ||
| 1884 | end -= 1; | |
| 1885 | } | |
| 1886 | ||
| 1887 | return end === str.length ? str : str.slice(0, end); | |
| 1888 | } | |
| 1889 | ||
| 1857 | 1890 | function normalizeValue(value) { |
| 1858 | 1891 | if (value === false || value == null) { |
| 1859 | 1892 | return value; |
| 1860 | 1893 | } |
| 1861 | 1894 | |
| 1862 | return utils$1.isArray(value) | |
| 1863 | ? value.map(normalizeValue) | |
| 1864 | : String(value).replace(/[\r\n]+$/, ''); | |
| 1895 | return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value)); | |
| 1865 | 1896 | } |
| 1866 | 1897 | |
| 1867 | 1898 | function parseTokens(str) { |
@@ -1943,6 +1974,7 @@ | ||
| 1943 | 1974 | _rewrite === true || |
| 1944 | 1975 | (_rewrite === undefined && self[key] !== false) |
| 1945 | 1976 | ) { |
| 1977 | assertValidHeaderValue(_value, _header); | |
| 1946 | 1978 | self[key || _header] = normalizeValue(_value); |
| 1947 | 1979 | } |
| 1948 | 1980 | } |
@@ -3554,7 +3586,7 @@ | ||
| 3554 | 3586 | ); |
| 3555 | 3587 | } |
| 3556 | 3588 | |
| 3557 | const VERSION$1 = "1.14.0"; | |
| 3589 | const VERSION$1 = "1.15.0"; | |
| 3558 | 3590 | |
| 3559 | 3591 | const validators$1 = {}; |
| 3560 | 3592 | |
@@ -3698,13 +3730,29 @@ | ||
| 3698 | 3730 | Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error()); |
| 3699 | 3731 | |
| 3700 | 3732 | // slice off the Error: ... line |
| 3701 | const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : ''; | |
| 3733 | const stack = (() => { | |
| 3734 | if (!dummy.stack) { | |
| 3735 | return ''; | |
| 3736 | } | |
| 3737 | ||
| 3738 | const firstNewlineIndex = dummy.stack.indexOf('\n'); | |
| 3739 | ||
| 3740 | return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1); | |
| 3741 | })(); | |
| 3702 | 3742 | try { |
| 3703 | 3743 | if (!err.stack) { |
| 3704 | 3744 | err.stack = stack; |
| 3705 | 3745 | // match without the 2 top stack lines |
| 3706 | } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) { | |
| 3707 | err.stack += '\n' + stack; | |
| 3746 | } else if (stack) { | |
| 3747 | const firstNewlineIndex = stack.indexOf('\n'); | |
| 3748 | const secondNewlineIndex = | |
| 3749 | firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1); | |
| 3750 | const stackWithoutTwoTopLines = | |
| 3751 | secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1); | |
| 3752 | ||
| 3753 | if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) { | |
| 3754 | err.stack += '\n' + stack; | |
| 3755 | } | |
| 3708 | 3756 | } |
| 3709 | 3757 | } catch (e) { |
| 3710 | 3758 | // ignore the case where "stack" is an un-writable property |
@@ -46,13 +46,29 @@ | ||
| 46 | 46 | Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error()); |
| 47 | 47 | |
| 48 | 48 | // slice off the Error: ... line |
| 49 | const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : ''; | |
| 49 | const stack = (() => { | |
| 50 | if (!dummy.stack) { | |
| 51 | return ''; | |
| 52 | } | |
| 53 | ||
| 54 | const firstNewlineIndex = dummy.stack.indexOf('\n'); | |
| 55 | ||
| 56 | return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1); | |
| 57 | })(); | |
| 50 | 58 | try { |
| 51 | 59 | if (!err.stack) { |
| 52 | 60 | err.stack = stack; |
| 53 | 61 | // match without the 2 top stack lines |
| 54 | } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) { | |
| 55 | err.stack += '\n' + stack; | |
| 62 | } else if (stack) { | |
| 63 | const firstNewlineIndex = stack.indexOf('\n'); | |
| 64 | const secondNewlineIndex = | |
| 65 | firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1); | |
| 66 | const stackWithoutTwoTopLines = | |
| 67 | secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1); | |
| 68 | ||
| 69 | if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) { | |
| 70 | err.stack += '\n' + stack; | |
| 71 | } | |
| 56 | 72 | } |
| 57 | 73 | } catch (e) { |
| 58 | 74 | // ignore the case where "stack" is an un-writable property |
@@ -5,18 +5,49 @@ | ||
| 5 | 5 | |
| 6 | 6 | const $internals = Symbol('internals'); |
| 7 | 7 | |
| 8 | const isValidHeaderValue = (value) => !/[\r\n]/.test(value); | |
| 9 | ||
| 10 | function assertValidHeaderValue(value, header) { | |
| 11 | if (value === false || value == null) { | |
| 12 | return; | |
| 13 | } | |
| 14 | ||
| 15 | if (utils.isArray(value)) { | |
| 16 | value.forEach((v) => assertValidHeaderValue(v, header)); | |
| 17 | return; | |
| 18 | } | |
| 19 | ||
| 20 | if (!isValidHeaderValue(String(value))) { | |
| 21 | throw new Error(`Invalid character in header content ["${header}"]`); | |
| 22 | } | |
| 23 | } | |
| 24 | ||
| 8 | 25 | function normalizeHeader(header) { |
| 9 | 26 | return header && String(header).trim().toLowerCase(); |
| 10 | 27 | } |
| 11 | 28 | |
| 29 | function stripTrailingCRLF(str) { | |
| 30 | let end = str.length; | |
| 31 | ||
| 32 | while (end > 0) { | |
| 33 | const charCode = str.charCodeAt(end - 1); | |
| 34 | ||
| 35 | if (charCode !== 10 && charCode !== 13) { | |
| 36 | break; | |
| 37 | } | |
| 38 | ||
| 39 | end -= 1; | |
| 40 | } | |
| 41 | ||
| 42 | return end === str.length ? str : str.slice(0, end); | |
| 43 | } | |
| 44 | ||
| 12 | 45 | function normalizeValue(value) { |
| 13 | 46 | if (value === false || value == null) { |
| 14 | 47 | return value; |
| 15 | 48 | } |
| 16 | 49 | |
| 17 | return utils.isArray(value) | |
| 18 | ? value.map(normalizeValue) | |
| 19 | : String(value).replace(/[\r\n]+$/, ''); | |
| 50 | return utils.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value)); | |
| 20 | 51 | } |
| 21 | 52 | |
| 22 | 53 | function parseTokens(str) { |
@@ -98,6 +129,7 @@ | ||
| 98 | 129 | _rewrite === true || |
| 99 | 130 | (_rewrite === undefined && self[key] !== false) |
| 100 | 131 | ) { |
| 132 | assertValidHeaderValue(_value, _header); | |
| 101 | 133 | self[key || _header] = normalizeValue(_value); |
| 102 | 134 | } |
| 103 | 135 | } |
@@ -23,6 +23,7 @@ | ||
| 23 | 23 | import readBlob from '../helpers/readBlob.js'; |
| 24 | 24 | import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js'; |
| 25 | 25 | import callbackify from '../helpers/callbackify.js'; |
| 26 | import shouldBypassProxy from '../helpers/shouldBypassProxy.js'; | |
| 26 | 27 | import { |
| 27 | 28 | progressEventReducer, |
| 28 | 29 | progressEventDecorator, |
@@ -192,7 +193,9 @@ | ||
| 192 | 193 | if (!proxy && proxy !== false) { |
| 193 | 194 | const proxyUrl = getProxyForUrl(location); |
| 194 | 195 | if (proxyUrl) { |
| 195 | proxy = new URL(proxyUrl); | |
| 196 | if (!shouldBypassProxy(location)) { | |
| 197 | proxy = new URL(proxyUrl); | |
| 198 | } | |
| 196 | 199 | } |
| 197 | 200 | } |
| 198 | 201 | if (proxy) { |
@@ -668,7 +671,6 @@ | ||
| 668 | 671 | protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path |
| 669 | 672 | ); |
| 670 | 673 | } |
| 671 | ||
| 672 | 674 | let transport; |
| 673 | 675 | const isHttpsRequest = isHttps.test(options.protocol); |
| 674 | 676 | options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; |
@@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "axios", |
| 3 | "version": "1.14.0", | |
| 3 | "version": "1.15.0", | |
| 4 | 4 | "description": "Promise based HTTP client for the browser and node.js", |
| 5 | 5 | "main": "./dist/node/axios.cjs", |
| 6 | 6 | "module": "./index.js", |
@@ -109,8 +109,11 @@ | ||
| 109 | 109 | "test:vitest:watch": "vitest", |
| 110 | 110 | "test:smoke:cjs:vitest": "npm --prefix tests/smoke/cjs run test:smoke:cjs:mocha", |
| 111 | 111 | "test:smoke:esm:vitest": "npm --prefix tests/smoke/esm run test:smoke:esm:vitest", |
| 112 | "test:smoke:deno": "deno task --cwd tests/smoke/deno test", | |
| 113 | "test:smoke:bun": "bun test --cwd tests/smoke/bun", | |
| 112 | 114 | "test:module:cjs": "npm --prefix tests/module/cjs run test:module:cjs", |
| 113 | 115 | "test:module:esm": "npm --prefix tests/module/esm run test:module:esm", |
| 116 | "docs:dev": "cd docs && npm run docs:dev", | |
| 114 | 117 | "start": "node ./sandbox/server.js", |
| 115 | 118 | "examples": "node ./examples/server.js", |
| 116 | 119 | "lint": "eslint lib/**/*.js", |
@@ -180,7 +180,7 @@ | ||
| 180 | 180 | |
| 181 | 181 | ### Bug Fixes |
| 182 | 182 | |
| 183 | - form-data npm pakcage ([#6970](https://github.com/axios/axios/issues/6970)) ([e72c193](https://github.com/axios/axios/commit/e72c193722530db538b19e5ddaaa4544d226b253)) | |
| 183 | - form-data npm package ([#6970](https://github.com/axios/axios/issues/6970)) ([e72c193](https://github.com/axios/axios/commit/e72c193722530db538b19e5ddaaa4544d226b253)) | |
| 184 | 184 | - prevent RangeError when using large Buffers ([#6961](https://github.com/axios/axios/issues/6961)) ([a2214ca](https://github.com/axios/axios/commit/a2214ca1bc60540baf2c80573cea3a0ff91ba9d1)) |
| 185 | 185 | - **types:** resolve type discrepancies between ESM and CJS TypeScript declaration files ([#6956](https://github.com/axios/axios/issues/6956)) ([8517aa1](https://github.com/axios/axios/commit/8517aa16f8d082fc1d5309c642220fa736159110)) |
| 186 | 186 | |
@@ -0,0 +1,106 @@ | ||
| 1 | const DEFAULT_PORTS = { | |
| 2 | http: 80, | |
| 3 | https: 443, | |
| 4 | ws: 80, | |
| 5 | wss: 443, | |
| 6 | ftp: 21, | |
| 7 | }; | |
| 8 | ||
| 9 | const parseNoProxyEntry = (entry) => { | |
| 10 | let entryHost = entry; | |
| 11 | let entryPort = 0; | |
| 12 | ||
| 13 | if (entryHost.charAt(0) === '[') { | |
| 14 | const bracketIndex = entryHost.indexOf(']'); | |
| 15 | ||
| 16 | if (bracketIndex !== -1) { | |
| 17 | const host = entryHost.slice(1, bracketIndex); | |
| 18 | const rest = entryHost.slice(bracketIndex + 1); | |
| 19 | ||
| 20 | if (rest.charAt(0) === ':' && /^\d+$/.test(rest.slice(1))) { | |
| 21 | entryPort = Number.parseInt(rest.slice(1), 10); | |
| 22 | } | |
| 23 | ||
| 24 | return [host, entryPort]; | |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | const firstColon = entryHost.indexOf(':'); | |
| 29 | const lastColon = entryHost.lastIndexOf(':'); | |
| 30 | ||
| 31 | if ( | |
| 32 | firstColon !== -1 && | |
| 33 | firstColon === lastColon && | |
| 34 | /^\d+$/.test(entryHost.slice(lastColon + 1)) | |
| 35 | ) { | |
| 36 | entryPort = Number.parseInt(entryHost.slice(lastColon + 1), 10); | |
| 37 | entryHost = entryHost.slice(0, lastColon); | |
| 38 | } | |
| 39 | ||
| 40 | return [entryHost, entryPort]; | |
| 41 | }; | |
| 42 | ||
| 43 | const normalizeNoProxyHost = (hostname) => { | |
| 44 | if (!hostname) { | |
| 45 | return hostname; | |
| 46 | } | |
| 47 | ||
| 48 | if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') { | |
| 49 | hostname = hostname.slice(1, -1); | |
| 50 | } | |
| 51 | ||
| 52 | return hostname.replace(/\.+$/, ''); | |
| 53 | }; | |
| 54 | ||
| 55 | export default function shouldBypassProxy(location) { | |
| 56 | let parsed; | |
| 57 | ||
| 58 | try { | |
| 59 | parsed = new URL(location); | |
| 60 | } catch (_err) { | |
| 61 | return false; | |
| 62 | } | |
| 63 | ||
| 64 | const noProxy = (process.env.no_proxy || process.env.NO_PROXY || '').toLowerCase(); | |
| 65 | ||
| 66 | if (!noProxy) { | |
| 67 | return false; | |
| 68 | } | |
| 69 | ||
| 70 | if (noProxy === '*') { | |
| 71 | return true; | |
| 72 | } | |
| 73 | ||
| 74 | const port = | |
| 75 | Number.parseInt(parsed.port, 10) || DEFAULT_PORTS[parsed.protocol.split(':', 1)[0]] || 0; | |
| 76 | ||
| 77 | const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase()); | |
| 78 | ||
| 79 | return noProxy.split(/[\s,]+/).some((entry) => { | |
| 80 | if (!entry) { | |
| 81 | return false; | |
| 82 | } | |
| 83 | ||
| 84 | let [entryHost, entryPort] = parseNoProxyEntry(entry); | |
| 85 | ||
| 86 | entryHost = normalizeNoProxyHost(entryHost); | |
| 87 | ||
| 88 | if (!entryHost) { | |
| 89 | return false; | |
| 90 | } | |
| 91 | ||
| 92 | if (entryPort && entryPort !== port) { | |
| 93 | return false; | |
| 94 | } | |
| 95 | ||
| 96 | if (entryHost.charAt(0) === '*') { | |
| 97 | entryHost = entryHost.slice(1); | |
| 98 | } | |
| 99 | ||
| 100 | if (entryHost.charAt(0) === '.') { | |
| 101 | return hostname.endsWith(entryHost); | |
| 102 | } | |
| 103 | ||
| 104 | return hostname === entryHost; | |
| 105 | }); | |
| 106 | } | |