2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Adding support for URLSearchParams

This commit is contained in:
Nick Uraltsev
2016-05-07 12:26:28 -07:00
parent ea375220a2
commit f20490eb6b
10 changed files with 108 additions and 20 deletions
+19
View File
@@ -142,6 +142,24 @@ function isStream(val) {
return isObject(val) && isFunction(val.pipe);
}
/**
* Determine if a value is a URLSearchParams object
*
* @param {Object} val The value to test
* @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)
);
}
/**
* Trim excess whitespace off the beginning and end of a string
*
@@ -259,6 +277,7 @@ module.exports = {
isBlob: isBlob,
isFunction: isFunction,
isStream: isStream,
isURLSearchParams: isURLSearchParams,
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,