CRM-15335 - Fix api explorer handling of number input
authorColeman Watts <coleman@civicrm.org>
Fri, 19 Sep 2014 18:34:57 +0000 (14:34 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 19 Sep 2014 18:34:57 +0000 (14:34 -0400)
templates/CRM/Admin/Page/APIExplorer.js

index 7f2ec390bfc554f52abfac6d18928237b4044c00..51709f3b729869b91c4563178539bf14548d4b4c 100644 (file)
       var first = val.charAt(0),
         last = val.slice(-1);
       // Simple types
-      if (val === 'true' || val === 'false' || val === 'null' || !isNaN(val)) {
+      if (val === 'true' || val === 'false' || val === 'null') {
         return eval(val);
       }
+      // Integers - quote any number that starts with 0 to avoid oddities
+      if (!isNaN(val) && val.search(/[^\d]/) < 0 && (val.length === 1 || first !== '0')) {
+        return parseInt(val, 10);
+      }
       // Quoted strings
       if ((first === '"' || first === "'") && last === first) {
         return val.slice(1, -1);