axios 1.18.1 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +297 -5
  3. package/dist/axios.js +728 -170
  4. package/dist/axios.min.js +3 -3
  5. package/dist/axios.min.js.map +1 -1
  6. package/dist/browser/axios.cjs +871 -188
  7. package/dist/esm/axios.js +871 -188
  8. package/dist/esm/axios.min.js +2 -2
  9. package/dist/esm/axios.min.js.map +1 -1
  10. package/dist/node/axios.cjs +1037 -225
  11. package/index.d.cts +102 -74
  12. package/index.d.ts +100 -68
  13. package/lib/adapters/fetch.js +64 -11
  14. package/lib/adapters/http.js +140 -67
  15. package/lib/adapters/xhr.js +52 -3
  16. package/lib/core/Axios.js +43 -20
  17. package/lib/core/AxiosError.js +33 -2
  18. package/lib/core/AxiosHeaders.js +124 -1
  19. package/lib/core/InterceptorManager.js +107 -8
  20. package/lib/core/buildFullPath.js +41 -15
  21. package/lib/core/dispatchRequest.js +8 -2
  22. package/lib/core/mergeConfig.js +19 -4
  23. package/lib/core/methodList.js +17 -0
  24. package/lib/core/setFormDataHeaders.js +27 -0
  25. package/lib/defaults/index.js +2 -1
  26. package/lib/env/data.js +1 -1
  27. package/lib/helpers/Http2Sessions.js +2 -0
  28. package/lib/helpers/HttpStatusCode.js +12 -1
  29. package/lib/helpers/combineURLs.js +11 -3
  30. package/lib/helpers/composeSignals.js +12 -1
  31. package/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
  32. package/lib/helpers/formDataToJSON.js +11 -5
  33. package/lib/helpers/fromDataURI.js +5 -4
  34. package/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  35. package/lib/helpers/parseHeaders.js +5 -3
  36. package/lib/helpers/progressEventReducer.js +4 -4
  37. package/lib/helpers/resolveConfig.js +5 -17
  38. package/lib/helpers/shouldBypassProxy.js +300 -5
  39. package/lib/helpers/throttle.js +3 -2
  40. package/lib/helpers/toFormData.js +17 -23
  41. package/lib/platform/node/classes/Buffer.js +11 -0
  42. package/lib/utils.js +151 -18
  43. package/package.json +21 -19
@@ -30,6 +30,124 @@ function parseTokens(str) {
30
30
  return tokens;
31
31
  }
32
32
 
33
+ const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
34
+
35
+ function trimOWS(value) {
36
+ let start = 0;
37
+ let end = value.length;
38
+
39
+ while (start < end) {
40
+ const code = value.charCodeAt(start);
41
+
42
+ if (code !== 0x09 && code !== 0x20) {
43
+ break;
44
+ }
45
+
46
+ start += 1;
47
+ }
48
+
49
+ while (end > start) {
50
+ const code = value.charCodeAt(end - 1);
51
+
52
+ if (code !== 0x09 && code !== 0x20) {
53
+ break;
54
+ }
55
+
56
+ end -= 1;
57
+ }
58
+
59
+ return start === 0 && end === value.length ? value : value.slice(start, end);
60
+ }
61
+
62
+ function decodeQuotedString(value) {
63
+ const last = value.length - 1;
64
+
65
+ if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
66
+ return value;
67
+ }
68
+
69
+ let decoded = '';
70
+
71
+ for (let i = 1; i < last; i++) {
72
+ const code = value.charCodeAt(i);
73
+
74
+ if (code === 0x22) {
75
+ return value;
76
+ }
77
+
78
+ if (code === 0x5c) {
79
+ i += 1;
80
+
81
+ if (i >= last) {
82
+ return value;
83
+ }
84
+ }
85
+
86
+ decoded += value[i];
87
+ }
88
+
89
+ return decoded;
90
+ }
91
+
92
+ function parseParameters(value) {
93
+ const parameters = Object.create(null);
94
+ const str = String(value);
95
+ let start = 0;
96
+ let quoted = false;
97
+ let escaped = false;
98
+
99
+ function parseParameter(end) {
100
+ const part = trimOWS(str.slice(start, end));
101
+ const equals = part.indexOf('=');
102
+
103
+ if (equals < 1) {
104
+ return;
105
+ }
106
+
107
+ const name = trimOWS(part.slice(0, equals));
108
+
109
+ if (!parameterNameRE.test(name)) {
110
+ return;
111
+ }
112
+
113
+ const normalizedName = name.toLowerCase();
114
+
115
+ if (
116
+ normalizedName === '__proto__' ||
117
+ normalizedName === 'constructor' ||
118
+ normalizedName === 'prototype'
119
+ ) {
120
+ return;
121
+ }
122
+
123
+ const parameterValue = trimOWS(part.slice(equals + 1));
124
+ parameters[normalizedName] = decodeQuotedString(parameterValue);
125
+ }
126
+
127
+ for (let i = 0; i < str.length; i++) {
128
+ const code = str.charCodeAt(i);
129
+
130
+ if (quoted) {
131
+ if (escaped) {
132
+ escaped = false;
133
+ } else if (code === 0x5c) {
134
+ escaped = true;
135
+ } else if (code === 0x22) {
136
+ quoted = false;
137
+ }
138
+ } else if (code === 0x22) {
139
+ quoted = true;
140
+ } else if (code === 0x2c || code === 0x3b) {
141
+ parseParameter(i);
142
+ start = i + 1;
143
+ }
144
+ }
145
+
146
+ parseParameter(str.length);
147
+
148
+ return parameters;
149
+ }
150
+
33
151
  const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
34
152
 
35
153
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
@@ -281,7 +399,8 @@ class AxiosHeaders {
281
399
  }
282
400
 
283
401
  getSetCookie() {
284
- return this.get('set-cookie') || [];
402
+ const value = this.get('set-cookie');
403
+ return utils.isArray(value) ? value : value == null || value === false ? [] : [value];
285
404
  }
286
405
 
287
406
  get [Symbol.toStringTag]() {
@@ -292,6 +411,10 @@ class AxiosHeaders {
292
411
  return thing instanceof this ? thing : new this(thing);
293
412
  }
294
413
 
414
+ static parseParameters(value) {
415
+ return parseParameters(value);
416
+ }
417
+
295
418
  static concat(first, ...targets) {
296
419
  const computed = new this(first);
297
420
 
@@ -2,9 +2,57 @@
2
2
 
3
3
  import utils from '../utils.js';
4
4
 
5
+ const $internals = Symbol('internals');
6
+
7
+ // `handlers` is public and may be replaced with a nullish value by user code;
8
+ // `clear()` has always tolerated that. Treat it as an empty stack rather than
9
+ // dereferencing it.
10
+ function countHandlers(handlers) {
11
+ return handlers ? handlers.length : 0;
12
+ }
13
+
14
+ function trimHandlers(handlers) {
15
+ if (!handlers) {
16
+ return;
17
+ }
18
+
19
+ while (handlers.length && handlers[handlers.length - 1] === null) {
20
+ handlers.pop();
21
+ }
22
+ }
23
+
24
+ function syncHandlerEntries(manager, internals) {
25
+ const handlers = manager.handlers;
26
+ const length = countHandlers(handlers);
27
+
28
+ if (handlers !== internals.handlersRef) {
29
+ internals.handlersRef = handlers;
30
+ internals.handlerEntries.clear();
31
+ } else if (length !== internals.handlersLength) {
32
+ if (!length) {
33
+ internals.handlerEntries.clear();
34
+ } else {
35
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
36
+ if (handlers[entry.index] !== entry.handler) {
37
+ internals.handlerEntries.delete(id);
38
+ }
39
+ });
40
+ }
41
+ }
42
+
43
+ internals.handlersLength = length;
44
+ }
45
+
5
46
  class InterceptorManager {
6
47
  constructor() {
7
48
  this.handlers = [];
49
+ this[$internals] = {
50
+ handlersRef: this.handlers,
51
+ handlersLength: this.handlers.length,
52
+ handlerEntries: new Map(),
53
+ iterationDepth: 0,
54
+ nextId: 0,
55
+ };
8
56
  }
9
57
 
10
58
  /**
@@ -17,13 +65,30 @@ class InterceptorManager {
17
65
  * @return {Number} An ID used to remove interceptor later
18
66
  */
19
67
  use(fulfilled, rejected, options) {
20
- this.handlers.push({
68
+ const handler = {
21
69
  fulfilled,
22
70
  rejected,
23
71
  synchronous: options ? options.synchronous : false,
24
72
  runWhen: options ? options.runWhen : null,
73
+ };
74
+ const internals = this[$internals];
75
+
76
+ if (this.handlers == null) {
77
+ this.handlers = [];
78
+ }
79
+
80
+ syncHandlerEntries(this, internals);
81
+
82
+ const id = internals.nextId++;
83
+
84
+ this.handlers.push(handler);
85
+ internals.handlerEntries.set(id, {
86
+ handler,
87
+ index: this.handlers.length - 1,
25
88
  });
26
- return this.handlers.length - 1;
89
+ internals.handlersLength = this.handlers.length;
90
+
91
+ return id;
27
92
  }
28
93
 
29
94
  /**
@@ -34,8 +99,27 @@ class InterceptorManager {
34
99
  * @returns {void}
35
100
  */
36
101
  eject(id) {
37
- if (this.handlers[id]) {
38
- this.handlers[id] = null;
102
+ const internals = this[$internals];
103
+
104
+ syncHandlerEntries(this, internals);
105
+
106
+ const entry = internals.handlerEntries.get(id);
107
+
108
+ if (entry) {
109
+ internals.handlerEntries.delete(id);
110
+
111
+ // Ignore IDs invalidated by clear or direct replacement of handlers.
112
+ if (this.handlers[entry.index] !== entry.handler) {
113
+ return;
114
+ }
115
+
116
+ this.handlers[entry.index] = null;
117
+
118
+ // Do not reuse an index while forEach is walking its length snapshot.
119
+ if (!internals.iterationDepth) {
120
+ trimHandlers(this.handlers);
121
+ internals.handlersLength = this.handlers.length;
122
+ }
39
123
  }
40
124
  }
41
125
 
@@ -47,6 +131,7 @@ class InterceptorManager {
47
131
  clear() {
48
132
  if (this.handlers) {
49
133
  this.handlers = [];
134
+ syncHandlerEntries(this, this[$internals]);
50
135
  }
51
136
  }
52
137
 
@@ -61,11 +146,25 @@ class InterceptorManager {
61
146
  * @returns {void}
62
147
  */
63
148
  forEach(fn) {
64
- utils.forEach(this.handlers, function forEachHandler(h) {
65
- if (h !== null) {
66
- fn(h);
149
+ const internals = this[$internals];
150
+
151
+ syncHandlerEntries(this, internals);
152
+
153
+ internals.iterationDepth++;
154
+
155
+ try {
156
+ utils.forEach(this.handlers, function forEachHandler(h) {
157
+ if (h !== null) {
158
+ fn(h);
159
+ }
160
+ });
161
+ } finally {
162
+ if (!--internals.iterationDepth) {
163
+ syncHandlerEntries(this, internals);
164
+ trimHandlers(this.handlers);
165
+ internals.handlersLength = countHandlers(this.handlers);
67
166
  }
68
- });
167
+ }
69
168
  }
70
169
  }
71
170
 
@@ -1,31 +1,57 @@
1
1
  'use strict';
2
2
 
3
- import AxiosError from './AxiosError.js';
3
+ import AxiosError, { REDACTED } from './AxiosError.js';
4
4
  import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
5
5
  import combineURLs from '../helpers/combineURLs.js';
6
+ import normalizeURLForProtocolCheck from '../helpers/normalizeURLForProtocolCheck.js';
6
7
 
7
8
  const malformedHttpProtocol = /^https?:(?!\/\/)/i;
8
- const httpProtocolControlCharacters = /[\t\n\r]/g;
9
9
 
10
- function stripLeadingC0ControlOrSpace(url) {
11
- let i = 0;
12
- while (i < url.length && url.charCodeAt(i) <= 0x20) {
13
- i++;
10
+ // Redact the parts of a URL that can carry secrets before it is embedded in an
11
+ // error message. AxiosError.toJSON() serializes `message` verbatim and errors
12
+ // are commonly logged, while the opt-in `config.redact` model only cleans
13
+ // config keys — it cannot reach the message. Redact only the genuinely
14
+ // sensitive substrings — userinfo (credentials), query parameter values and
15
+ // fragment contents — with the same REDACTED marker the config redaction uses,
16
+ // while keeping the scheme, host, path and parameter names so the offending
17
+ // request stays accurately identifiable.
18
+ function redactFragment(fragment) {
19
+ if (!fragment) {
20
+ return fragment;
14
21
  }
15
- return url.slice(i);
22
+
23
+ return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
24
+ return `${separator}${parameterName}${REDACTED}`;
25
+ });
16
26
  }
17
27
 
18
- function normalizeURLForProtocolCheck(url) {
19
- return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
28
+ function redactSensitiveURLParts(url) {
29
+ const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
30
+ const fragmentIndex = redactedURL.indexOf('#');
31
+ const urlWithoutFragment =
32
+ fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
33
+ const redactedURLWithoutFragment = urlWithoutFragment.replace(
34
+ /([?&][^=&#]*=)[^&#]*/g,
35
+ `$1${REDACTED}`
36
+ );
37
+
38
+ if (fragmentIndex === -1) {
39
+ return redactedURLWithoutFragment;
40
+ }
41
+
42
+ return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
20
43
  }
21
44
 
22
45
  function assertValidHttpProtocolURL(url, config) {
23
- if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
24
- throw new AxiosError(
25
- 'Invalid URL: missing "//" after protocol',
26
- AxiosError.ERR_INVALID_URL,
27
- config
28
- );
46
+ if (typeof url === 'string') {
47
+ const normalizedURL = normalizeURLForProtocolCheck(url);
48
+ if (malformedHttpProtocol.test(normalizedURL)) {
49
+ throw new AxiosError(
50
+ `Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
51
+ AxiosError.ERR_INVALID_URL,
52
+ config
53
+ );
54
+ }
29
55
  }
30
56
  }
31
57
 
@@ -6,6 +6,7 @@ import defaults from '../defaults/index.js';
6
6
  import CanceledError from '../cancel/CanceledError.js';
7
7
  import AxiosHeaders from '../core/AxiosHeaders.js';
8
8
  import adapters from '../adapters/adapters.js';
9
+ import utils from '../utils.js';
9
10
 
10
11
  /**
11
12
  * Throws a `CanceledError` if cancellation has been requested.
@@ -31,10 +32,15 @@ function throwIfCancellationRequested(config) {
31
32
  *
32
33
  * @returns {Promise} The Promise to be fulfilled
33
34
  */
34
- export default function dispatchRequest(config) {
35
+ export default function dispatchRequest(_config) {
36
+ // Interceptors may replace the merged config with an ordinary object. Flatten
37
+ // it at the dispatch boundary so shared prototype members cannot become
38
+ // request behavior, while preserving intentional template/class members.
39
+ const config = utils.toSafeFlatObject(_config);
40
+
35
41
  throwIfCancellationRequested(config);
36
42
 
37
- config.headers = AxiosHeaders.from(config.headers);
43
+ config.headers = AxiosHeaders.from(utils.getSafeProp(config, 'headers'));
38
44
 
39
45
  // Transform request data
40
46
  config.data = transformData.call(config, config.transformRequest);
@@ -5,6 +5,17 @@ import AxiosHeaders from './AxiosHeaders.js';
5
5
 
6
6
  const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
7
7
 
8
+ const ownEnumerableKeys = (thing) => {
9
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
10
+ return Object.keys(thing).concat(
11
+ Object.getOwnPropertySymbols(thing).filter(
12
+ (symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
13
+ )
14
+ );
15
+ }
16
+ return Object.keys(thing);
17
+ };
18
+
8
19
  /**
9
20
  * Config-specific merge-function which creates a new config-object
10
21
  * by merging two configuration objects together.
@@ -70,7 +81,9 @@ export default function mergeConfig(config1, config2) {
70
81
  }
71
82
 
72
83
  function getMergedTransitionalOption(prop) {
73
- const transitional2 = utils.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
84
+ const transitional2 = utils.hasOwnProp(config2, 'transitional')
85
+ ? config2.transitional
86
+ : undefined;
74
87
 
75
88
  if (!utils.isUndefined(transitional2)) {
76
89
  if (utils.isPlainObject(transitional2)) {
@@ -82,7 +95,9 @@ export default function mergeConfig(config1, config2) {
82
95
  }
83
96
  }
84
97
 
85
- const transitional1 = utils.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
98
+ const transitional1 = utils.hasOwnProp(config1, 'transitional')
99
+ ? config1.transitional
100
+ : undefined;
86
101
 
87
102
  if (utils.isPlainObject(transitional1) && utils.hasOwnProp(transitional1, prop)) {
88
103
  return transitional1[prop];
@@ -109,7 +124,7 @@ export default function mergeConfig(config1, config2) {
109
124
  transformResponse: defaultToConfig2,
110
125
  paramsSerializer: defaultToConfig2,
111
126
  timeout: defaultToConfig2,
112
- timeoutMessage: defaultToConfig2,
127
+ timeoutErrorMessage: defaultToConfig2,
113
128
  withCredentials: defaultToConfig2,
114
129
  withXSRFToken: defaultToConfig2,
115
130
  adapter: defaultToConfig2,
@@ -134,7 +149,7 @@ export default function mergeConfig(config1, config2) {
134
149
  mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
135
150
  };
136
151
 
137
- utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
152
+ utils.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
138
153
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
139
154
  const merge = utils.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
140
155
  const a = utils.hasOwnProp(config1, prop) ? config1[prop] : undefined;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const methodList = Object.freeze([
4
+ 'get',
5
+ 'delete',
6
+ 'head',
7
+ 'options',
8
+ 'post',
9
+ 'put',
10
+ 'patch',
11
+ 'purge',
12
+ 'link',
13
+ 'unlink',
14
+ 'query',
15
+ ]);
16
+
17
+ export default methodList;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
4
+
5
+ /**
6
+ * Apply the headers generated by a FormData implementation to the request headers,
7
+ * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
8
+ * content-* headers; otherwise merge all of them.
9
+ *
10
+ * @param {AxiosHeaders} headers - the request headers to mutate
11
+ * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
12
+ * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
13
+ *
14
+ * @returns {void}
15
+ */
16
+ export default function setFormDataHeaders(headers, formHeaders, policy) {
17
+ if (policy !== 'content-only') {
18
+ headers.set(formHeaders);
19
+ return;
20
+ }
21
+
22
+ Object.entries(formHeaders || {}).forEach(([key, val]) => {
23
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
24
+ headers.set(key, val);
25
+ }
26
+ });
27
+ }
@@ -7,6 +7,7 @@ import toFormData from '../helpers/toFormData.js';
7
7
  import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
8
8
  import platform from '../platform/index.js';
9
9
  import formDataToJSON from '../helpers/formDataToJSON.js';
10
+ import methodList from '../core/methodList.js';
10
11
 
11
12
  const own = (obj, key) => (obj != null && utils.hasOwnProp(obj, key) ? obj[key] : undefined);
12
13
 
@@ -170,7 +171,7 @@ const defaults = {
170
171
  },
171
172
  };
172
173
 
173
- utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
174
+ utils.forEach(methodList, (method) => {
174
175
  defaults.headers[method] = {};
175
176
  });
176
177
 
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.18.1";
1
+ export const VERSION = "1.20.0";
@@ -15,6 +15,7 @@ class Http2Sessions {
15
15
 
16
16
  getSession(authority, options) {
17
17
  options = Object.assign(
18
+ Object.create(null),
18
19
  {
19
20
  sessionTimeout: 1000,
20
21
  },
@@ -105,6 +106,7 @@ class Http2Sessions {
105
106
  }
106
107
 
107
108
  session.once('close', removeSession);
109
+ session.once('error', removeSession);
108
110
 
109
111
  let entry = [session, options];
110
112
 
@@ -35,14 +35,22 @@ const HttpStatusCode = {
35
35
  Gone: 410,
36
36
  LengthRequired: 411,
37
37
  PreconditionFailed: 412,
38
+ /**
39
+ * @deprecated Use `ContentTooLarge` instead.
40
+ */
38
41
  PayloadTooLarge: 413,
42
+ ContentTooLarge: 413,
39
43
  UriTooLong: 414,
40
44
  UnsupportedMediaType: 415,
41
45
  RangeNotSatisfiable: 416,
42
46
  ExpectationFailed: 417,
43
47
  ImATeapot: 418,
44
48
  MisdirectedRequest: 421,
49
+ /**
50
+ * @deprecated Use `UnprocessableContent` instead.
51
+ */
45
52
  UnprocessableEntity: 422,
53
+ UnprocessableContent: 422,
46
54
  Locked: 423,
47
55
  FailedDependency: 424,
48
56
  TooEarly: 425,
@@ -62,6 +70,7 @@ const HttpStatusCode = {
62
70
  LoopDetected: 508,
63
71
  NotExtended: 510,
64
72
  NetworkAuthenticationRequired: 511,
73
+ WebServerReturnsAnUnknownError: 520,
65
74
  WebServerIsDown: 521,
66
75
  ConnectionTimedOut: 522,
67
76
  OriginIsUnreachable: 523,
@@ -71,7 +80,9 @@ const HttpStatusCode = {
71
80
  };
72
81
 
73
82
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
74
- HttpStatusCode[value] = key;
83
+ if (HttpStatusCode[value] === undefined) {
84
+ HttpStatusCode[value] = key;
85
+ }
75
86
  });
76
87
 
77
88
  export default HttpStatusCode;
@@ -9,7 +9,15 @@
9
9
  * @returns {string} The combined URL
10
10
  */
11
11
  export default function combineURLs(baseURL, relativeURL) {
12
- return relativeURL
13
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
14
- : baseURL;
12
+ if (!relativeURL) {
13
+ return baseURL;
14
+ }
15
+
16
+ let end = baseURL.length;
17
+
18
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
19
+ end--;
20
+ }
21
+
22
+ return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
15
23
  }
@@ -45,7 +45,18 @@ const composeSignals = (signals, timeout) => {
45
45
  signals = null;
46
46
  };
47
47
 
48
- signals.forEach((signal) => signal.addEventListener('abort', onabort, { once: true }));
48
+ signals.forEach((signal) => {
49
+ if (aborted) {
50
+ return;
51
+ }
52
+
53
+ if (signal.aborted) {
54
+ onabort.call(signal);
55
+ return;
56
+ }
57
+
58
+ signal.addEventListener('abort', onabort, { once: true });
59
+ });
49
60
 
50
61
  const { signal } = controller;
51
62