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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user