2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-27 14:47:43 +03:00

Modifying isURLSearchParams function to use instanceof instead of duck typing

This commit is contained in:
Nick Uraltsev
2016-05-18 18:47:34 -07:00
parent f20490eb6b
commit 2b8d89a65e
4 changed files with 4 additions and 12 deletions
+1 -9
View File
@@ -149,15 +149,7 @@ function isStream(val) {
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
function isURLSearchParams(val) {
// Object.prototype.toString will return [object Object] for a polyfill
// Hence, we have to use duck typing
return toString.call(val) === '[object URLSearchParams]' || (
isObject(val) &&
isFunction(val.append) &&
isFunction(val.delete) &&
isFunction(val.get) &&
isFunction(val.set)
);
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
}
/**
+3
View File
@@ -1,6 +1,9 @@
// Polyfill ES6 Promise
require('es6-promise').polyfill();
// Polyfill URLSearchParams
URLSearchParams = require('url-search-params');
// Import axios
axios = require('../../index');
-2
View File
@@ -1,5 +1,3 @@
var URLSearchParams = require('url-search-params');
describe('requests', function () {
beforeEach(function () {
jasmine.Ajax.install();
-1
View File
@@ -1,6 +1,5 @@
var utils = require('../../../lib/utils');
var Stream = require('stream');
var URLSearchParams = require('url-search-params');
describe('utils::isX', function () {
it('should validate Array', function () {