(obj, prefix)
| 4 | var toString = Object.prototype.toString; |
| 5 | |
| 6 | function stringify(obj, prefix) { |
| 7 | if (prefix && (obj === null || typeof obj == 'undefined')) { |
| 8 | return prefix + '='; |
| 9 | } else if (toString.call(obj) == '[object Array]') { |
| 10 | return stringifyArray(obj, prefix); |
| 11 | } else if (toString.call(obj) == '[object Object]') { |
| 12 | return stringifyObject(obj, prefix); |
| 13 | } else if (toString.call(obj) == '[object Date]') { |
| 14 | return obj.toISOString(); |
| 15 | } else if (prefix) { // string inside array or hash |
| 16 | return prefix + '=' + encodeURIComponent(String(obj)); |
| 17 | } else if (String(obj).indexOf('=') !== -1) { // string with equal sign |
| 18 | return String(obj); |
| 19 | } else { |
| 20 | throw new TypeError('Cannot build a querystring out of: ' + obj); |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | function stringifyArray(arr, prefix) { |
| 25 | var ret = []; |
no test coverage detected
searching dependent graphs…