axios 0.27.0 → 0.27.1

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.
@@ -17,6 +17,8 @@ var CanceledError = require('../cancel/CanceledError');
17
17
 
18
18
  var isHttps = /https:?/;
19
19
 
20
+ var supportedProtocols = [ 'http:', 'https:', 'file:' ];
21
+
20
22
  /**
21
23
  *
22
24
  * @param {http.ClientRequestArgs} options
@@ -129,9 +131,9 @@ module.exports = function httpAdapter(config) {
129
131
  // Parse url
130
132
  var fullPath = buildFullPath(config.baseURL, config.url);
131
133
  var parsed = url.parse(fullPath);
132
- var protocol = utils.getProtocol(parsed.protocol);
134
+ var protocol = parsed.protocol || supportedProtocols[0];
133
135
 
134
- if (!utils.supportedProtocols.includes(protocol)) {
136
+ if (supportedProtocols.indexOf(protocol) === -1) {
135
137
  return reject(new AxiosError(
136
138
  'Unsupported protocol ' + protocol,
137
139
  AxiosError.ERR_BAD_REQUEST,
@@ -7,7 +7,6 @@ var buildURL = require('./../helpers/buildURL');
7
7
  var buildFullPath = require('../core/buildFullPath');
8
8
  var parseHeaders = require('./../helpers/parseHeaders');
9
9
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
10
- var url = require('url');
11
10
  var transitionalDefaults = require('../defaults/transitional');
12
11
  var AxiosError = require('../core/AxiosError');
13
12
  var CanceledError = require('../cancel/CanceledError');
@@ -38,8 +37,6 @@ module.exports = function xhrAdapter(config) {
38
37
  }
39
38
 
40
39
  var fullPath = buildFullPath(config.baseURL, config.url);
41
- var parsed = url.parse(fullPath);
42
- var protocol = utils.getProtocol(parsed.protocol);
43
40
 
44
41
  request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
45
42
 
@@ -206,16 +203,15 @@ module.exports = function xhrAdapter(config) {
206
203
  requestData = null;
207
204
  }
208
205
 
209
- if (parsed.path === null) {
210
- reject(new AxiosError('Malformed URL ' + fullPath, AxiosError.ERR_BAD_REQUEST, config));
211
- return;
212
- }
206
+ var tokens = fullPath.split(':', 2);
207
+ var protocol = tokens.length > 1 && tokens[0];
213
208
 
214
- if (!utils.supportedProtocols.includes(protocol)) {
215
- reject(new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_BAD_REQUEST, config));
209
+ if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
210
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
216
211
  return;
217
212
  }
218
213
 
214
+
219
215
  // Send the request
220
216
  request.send(requestData);
221
217
  });
package/lib/env/data.js CHANGED
@@ -1,3 +1,3 @@
1
1
  module.exports = {
2
- "version": "0.27.0"
2
+ "version": "0.27.1"
3
3
  };
package/lib/utils.js CHANGED
@@ -22,22 +22,6 @@ function kindOfTest(type) {
22
22
  };
23
23
  }
24
24
 
25
- /**
26
- * Array with axios supported protocols.
27
- */
28
- var supportedProtocols = [ 'http:', 'https:', 'file:' ];
29
-
30
- /**
31
- * Returns URL protocol passed as param if is not undefined or null,
32
- * otherwise just returns 'http:'
33
- *
34
- * @param {String} protocol The String value of URL protocol
35
- * @returns {String} Protocol if the value is not undefined or null
36
- */
37
- function getProtocol(protocol) {
38
- return protocol || 'http:';
39
- }
40
-
41
25
  /**
42
26
  * Determine if a value is an Array
43
27
  *
@@ -453,8 +437,6 @@ var isTypedArray = (function(TypedArray) {
453
437
  })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
454
438
 
455
439
  module.exports = {
456
- supportedProtocols: supportedProtocols,
457
- getProtocol: getProtocol,
458
440
  isArray: isArray,
459
441
  isArrayBuffer: isArrayBuffer,
460
442
  isBuffer: isBuffer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",