[OpenLayers-Commits] r12217 - in trunk/openlayers: lib/OpenLayers tests

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Aug 8 09:43:15 EDT 2011


Author: crschmidt
Date: 2011-08-08 06:43:14 -0700 (Mon, 08 Aug 2011)
New Revision: 12217

Modified:
   trunk/openlayers/lib/OpenLayers/Util.js
   trunk/openlayers/tests/Util.html
Log:
Thanks to a patch from greid, fix case where "" is passed into getParameters,
which would previously have weird behavior. (Pullup #3408)


Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js	2011-08-08 13:22:59 UTC (rev 12216)
+++ trunk/openlayers/lib/OpenLayers/Util.js	2011-08-08 13:43:14 UTC (rev 12217)
@@ -943,14 +943,15 @@
  * 
  * Parameters:
  * url - {String} Optional url used to extract the query string.
- *                If null, query string is taken from page location.
+ *                If url is null or is not supplied, query string is taken 
+ *                from the page location.
  * 
  * Returns:
  * {Object} An object of key/value pairs from the query string.
  */
 OpenLayers.Util.getParameters = function(url) {
     // if no url specified, take it from the location bar
-    url = url || window.location.href;
+    url = (url === null || url === undefined) ? window.location.href : url;
 
     //parse out parameters portion of url string
     var paramsString = "";

Modified: trunk/openlayers/tests/Util.html
===================================================================
--- trunk/openlayers/tests/Util.html	2011-08-08 13:22:59 UTC (rev 12216)
+++ trunk/openlayers/tests/Util.html	2011-08-08 13:43:14 UTC (rev 12217)
@@ -952,8 +952,17 @@
     }
 
     function test_Util_getParameters(t) {
-        t.plan(17);
+        t.plan(20);
 
+        t.eq(OpenLayers.Util.getParameters(''), {},
+                "getParameters works when the given argument is empty string");
+
+        t.eq(OpenLayers.Util.getParameters(), {},
+                "getParameters works with optional argument");
+
+        t.eq(OpenLayers.Util.getParameters(null), {},
+                "getParameters works with optional argument");
+
         t.eq(OpenLayers.Util.getParameters('http://www.example.com'), {},
              "getParameters works when args = ''");
         t.eq(OpenLayers.Util.getParameters('http://www.example.com?'), {},



More information about the Commits mailing list