Prechádzať zdrojové kódy

browser compatability changes to querystring module

Caolan McMahon 14 rokov pred
rodič
commit
4951c3b9c7
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  1. 6 1
      commonjs/kanso/querystring.js

+ 6 - 1
commonjs/kanso/querystring.js

@@ -2,6 +2,11 @@
  * From node.js v0.2.6
  */
 
+// Browser-friendly version of Array.isArray
+var _isArray = function(obj) {
+    return toString.call(obj) === '[object Array]';
+};
+
 // Query String Utilities
 
 var QueryString = exports;
@@ -97,7 +102,7 @@ QueryString.parse = function (qs, sep, eq) {
             var end = offset + all.length === key.length;
             name = name || nameInBrackets || nameIn2Quotes || nameIn1Quotes;
             next = end ? value : {};
-            if (Array.isArray(res[name])) {
+            if (_isArray(res[name])) {
                 res[name].push(next);
                 res = next;
             }