2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +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;
}
/**