axios 0.18.1 → 0.19.2

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -6,48 +6,48 @@ module.exports = (
6
6
  utils.isStandardBrowserEnv() ?
7
7
 
8
8
  // Standard browser envs support document.cookie
9
- (function standardBrowserEnv() {
10
- return {
11
- write: function write(name, value, expires, path, domain, secure) {
12
- var cookie = [];
13
- cookie.push(name + '=' + encodeURIComponent(value));
14
-
15
- if (utils.isNumber(expires)) {
16
- cookie.push('expires=' + new Date(expires).toGMTString());
9
+ (function standardBrowserEnv() {
10
+ return {
11
+ write: function write(name, value, expires, path, domain, secure) {
12
+ var cookie = [];
13
+ cookie.push(name + '=' + encodeURIComponent(value));
14
+
15
+ if (utils.isNumber(expires)) {
16
+ cookie.push('expires=' + new Date(expires).toGMTString());
17
+ }
18
+
19
+ if (utils.isString(path)) {
20
+ cookie.push('path=' + path);
21
+ }
22
+
23
+ if (utils.isString(domain)) {
24
+ cookie.push('domain=' + domain);
25
+ }
26
+
27
+ if (secure === true) {
28
+ cookie.push('secure');
29
+ }
30
+
31
+ document.cookie = cookie.join('; ');
32
+ },
33
+
34
+ read: function read(name) {
35
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36
+ return (match ? decodeURIComponent(match[3]) : null);
37
+ },
38
+
39
+ remove: function remove(name) {
40
+ this.write(name, '', Date.now() - 86400000);
17
41
  }
18
-
19
- if (utils.isString(path)) {
20
- cookie.push('path=' + path);
21
- }
22
-
23
- if (utils.isString(domain)) {
24
- cookie.push('domain=' + domain);
25
- }
26
-
27
- if (secure === true) {
28
- cookie.push('secure');
29
- }
30
-
31
- document.cookie = cookie.join('; ');
32
- },
33
-
34
- read: function read(name) {
35
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36
- return (match ? decodeURIComponent(match[3]) : null);
37
- },
38
-
39
- remove: function remove(name) {
40
- this.write(name, '', Date.now() - 86400000);
41
- }
42
- };
43
- })() :
42
+ };
43
+ })() :
44
44
 
45
45
  // Non standard browser env (web workers, react-native) lack needed support.
46
- (function nonStandardBrowserEnv() {
47
- return {
48
- write: function write() {},
49
- read: function read() { return null; },
50
- remove: function remove() {}
51
- };
52
- })()
46
+ (function nonStandardBrowserEnv() {
47
+ return {
48
+ write: function write() {},
49
+ read: function read() { return null; },
50
+ remove: function remove() {}
51
+ };
52
+ })()
53
53
  );
@@ -7,62 +7,62 @@ module.exports = (
7
7
 
8
8
  // Standard browser envs have full support of the APIs needed to test
9
9
  // whether the request URL is of the same origin as current location.
10
- (function standardBrowserEnv() {
11
- var msie = /(msie|trident)/i.test(navigator.userAgent);
12
- var urlParsingNode = document.createElement('a');
13
- var originURL;
10
+ (function standardBrowserEnv() {
11
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
12
+ var urlParsingNode = document.createElement('a');
13
+ var originURL;
14
14
 
15
- /**
15
+ /**
16
16
  * Parse a URL to discover it's components
17
17
  *
18
18
  * @param {String} url The URL to be parsed
19
19
  * @returns {Object}
20
20
  */
21
- function resolveURL(url) {
22
- var href = url;
21
+ function resolveURL(url) {
22
+ var href = url;
23
23
 
24
- if (msie) {
24
+ if (msie) {
25
25
  // IE needs attribute set twice to normalize properties
26
- urlParsingNode.setAttribute('href', href);
27
- href = urlParsingNode.href;
28
- }
26
+ urlParsingNode.setAttribute('href', href);
27
+ href = urlParsingNode.href;
28
+ }
29
29
 
30
- urlParsingNode.setAttribute('href', href);
30
+ urlParsingNode.setAttribute('href', href);
31
31
 
32
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33
- return {
34
- href: urlParsingNode.href,
35
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36
- host: urlParsingNode.host,
37
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39
- hostname: urlParsingNode.hostname,
40
- port: urlParsingNode.port,
41
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42
- urlParsingNode.pathname :
43
- '/' + urlParsingNode.pathname
44
- };
45
- }
32
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33
+ return {
34
+ href: urlParsingNode.href,
35
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36
+ host: urlParsingNode.host,
37
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39
+ hostname: urlParsingNode.hostname,
40
+ port: urlParsingNode.port,
41
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42
+ urlParsingNode.pathname :
43
+ '/' + urlParsingNode.pathname
44
+ };
45
+ }
46
46
 
47
- originURL = resolveURL(window.location.href);
47
+ originURL = resolveURL(window.location.href);
48
48
 
49
- /**
49
+ /**
50
50
  * Determine if a URL shares the same origin as the current location
51
51
  *
52
52
  * @param {String} requestURL The URL to test
53
53
  * @returns {boolean} True if URL shares the same origin, otherwise false
54
54
  */
55
- return function isURLSameOrigin(requestURL) {
56
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57
- return (parsed.protocol === originURL.protocol &&
55
+ return function isURLSameOrigin(requestURL) {
56
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57
+ return (parsed.protocol === originURL.protocol &&
58
58
  parsed.host === originURL.host);
59
- };
60
- })() :
59
+ };
60
+ })() :
61
61
 
62
62
  // Non standard browser envs (web workers, react-native) lack needed support.
63
- (function nonStandardBrowserEnv() {
64
- return function isURLSameOrigin() {
65
- return true;
66
- };
67
- })()
63
+ (function nonStandardBrowserEnv() {
64
+ return function isURLSameOrigin() {
65
+ return true;
66
+ };
67
+ })()
68
68
  );
package/lib/utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var bind = require('./helpers/bind');
4
- var isBuffer = require('is-buffer');
5
4
 
6
5
  /*global toString:true*/
7
6
 
@@ -19,6 +18,27 @@ function isArray(val) {
19
18
  return toString.call(val) === '[object Array]';
20
19
  }
21
20
 
21
+ /**
22
+ * Determine if a value is undefined
23
+ *
24
+ * @param {Object} val The value to test
25
+ * @returns {boolean} True if the value is undefined, otherwise false
26
+ */
27
+ function isUndefined(val) {
28
+ return typeof val === 'undefined';
29
+ }
30
+
31
+ /**
32
+ * Determine if a value is a Buffer
33
+ *
34
+ * @param {Object} val The value to test
35
+ * @returns {boolean} True if value is a Buffer, otherwise false
36
+ */
37
+ function isBuffer(val) {
38
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
39
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
40
+ }
41
+
22
42
  /**
23
43
  * Determine if a value is an ArrayBuffer
24
44
  *
@@ -75,16 +95,6 @@ function isNumber(val) {
75
95
  return typeof val === 'number';
76
96
  }
77
97
 
78
- /**
79
- * Determine if a value is undefined
80
- *
81
- * @param {Object} val The value to test
82
- * @returns {boolean} True if the value is undefined, otherwise false
83
- */
84
- function isUndefined(val) {
85
- return typeof val === 'undefined';
86
- }
87
-
88
98
  /**
89
99
  * Determine if a value is an Object
90
100
  *
@@ -177,9 +187,13 @@ function trim(str) {
177
187
  *
178
188
  * react-native:
179
189
  * navigator.product -> 'ReactNative'
190
+ * nativescript
191
+ * navigator.product -> 'NativeScript' or 'NS'
180
192
  */
181
193
  function isStandardBrowserEnv() {
182
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
194
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
195
+ navigator.product === 'NativeScript' ||
196
+ navigator.product === 'NS')) {
183
197
  return false;
184
198
  }
185
199
  return (
@@ -260,6 +274,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
260
274
  return result;
261
275
  }
262
276
 
277
+ /**
278
+ * Function equal to merge with the difference being that no reference
279
+ * to original objects is kept.
280
+ *
281
+ * @see merge
282
+ * @param {Object} obj1 Object to merge
283
+ * @returns {Object} Result of all merge properties
284
+ */
285
+ function deepMerge(/* obj1, obj2, obj3, ... */) {
286
+ var result = {};
287
+ function assignValue(val, key) {
288
+ if (typeof result[key] === 'object' && typeof val === 'object') {
289
+ result[key] = deepMerge(result[key], val);
290
+ } else if (typeof val === 'object') {
291
+ result[key] = deepMerge({}, val);
292
+ } else {
293
+ result[key] = val;
294
+ }
295
+ }
296
+
297
+ for (var i = 0, l = arguments.length; i < l; i++) {
298
+ forEach(arguments[i], assignValue);
299
+ }
300
+ return result;
301
+ }
302
+
263
303
  /**
264
304
  * Extends object a by mutably adding to it the properties of object b.
265
305
  *
@@ -298,6 +338,7 @@ module.exports = {
298
338
  isStandardBrowserEnv: isStandardBrowserEnv,
299
339
  forEach: forEach,
300
340
  merge: merge,
341
+ deepMerge: deepMerge,
301
342
  extend: extend,
302
343
  trim: trim
303
344
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "0.18.1",
3
+ "version": "0.19.2",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
12
12
  "postversion": "git push && git push --tags",
13
13
  "examples": "node ./examples/server.js",
14
- "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
14
+ "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
15
+ "fix": "eslint --fix lib/**/*.js"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -31,48 +32,48 @@
31
32
  },
32
33
  "homepage": "https://github.com/axios/axios",
33
34
  "devDependencies": {
34
- "bundlesize": "^0.5.7",
35
- "coveralls": "^2.11.9",
36
- "es6-promise": "^4.0.5",
37
- "grunt": "^1.0.1",
35
+ "bundlesize": "^0.17.0",
36
+ "coveralls": "^3.0.0",
37
+ "es6-promise": "^4.2.4",
38
+ "grunt": "^1.0.2",
38
39
  "grunt-banner": "^0.6.0",
39
40
  "grunt-cli": "^1.2.0",
40
- "grunt-contrib-clean": "^1.0.0",
41
- "grunt-contrib-nodeunit": "^1.0.0",
41
+ "grunt-contrib-clean": "^1.1.0",
42
42
  "grunt-contrib-watch": "^1.0.0",
43
- "grunt-eslint": "^19.0.0",
43
+ "grunt-eslint": "^20.1.0",
44
44
  "grunt-karma": "^2.0.0",
45
- "grunt-ts": "^6.0.0-beta.3",
45
+ "grunt-mocha-test": "^0.13.3",
46
+ "grunt-ts": "^6.0.0-beta.19",
46
47
  "grunt-webpack": "^1.0.18",
47
48
  "istanbul-instrumenter-loader": "^1.0.0",
48
49
  "jasmine-core": "^2.4.1",
49
50
  "karma": "^1.3.0",
50
- "karma-chrome-launcher": "^2.0.0",
51
- "karma-coverage": "^1.0.0",
52
- "karma-firefox-launcher": "^1.0.0",
53
- "karma-jasmine": "^1.0.2",
51
+ "karma-chrome-launcher": "^2.2.0",
52
+ "karma-coverage": "^1.1.1",
53
+ "karma-firefox-launcher": "^1.1.0",
54
+ "karma-jasmine": "^1.1.1",
54
55
  "karma-jasmine-ajax": "^0.1.13",
55
56
  "karma-opera-launcher": "^1.0.0",
56
57
  "karma-safari-launcher": "^1.0.0",
57
- "karma-sauce-launcher": "^1.1.0",
58
+ "karma-sauce-launcher": "^1.2.0",
58
59
  "karma-sinon": "^1.0.5",
59
60
  "karma-sourcemap-loader": "^0.3.7",
60
61
  "karma-webpack": "^1.7.0",
61
62
  "load-grunt-tasks": "^3.5.2",
62
63
  "minimist": "^1.2.0",
63
- "sinon": "^1.17.4",
64
+ "mocha": "^5.2.0",
65
+ "sinon": "^4.5.0",
66
+ "typescript": "^2.8.1",
67
+ "url-search-params": "^0.10.0",
64
68
  "webpack": "^1.13.1",
65
- "webpack-dev-server": "^1.14.1",
66
- "url-search-params": "^0.6.1",
67
- "typescript": "^2.0.3"
69
+ "webpack-dev-server": "^1.14.1"
68
70
  },
69
71
  "browser": {
70
72
  "./lib/adapters/http.js": "./lib/adapters/xhr.js"
71
73
  },
72
74
  "typings": "./index.d.ts",
73
75
  "dependencies": {
74
- "follow-redirects": "1.5.10",
75
- "is-buffer": "^2.0.2"
76
+ "follow-redirects": "1.5.10"
76
77
  },
77
78
  "bundlesize": [
78
79
  {