diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index a455e77948..6d7681bf9b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -943,14 +943,15 @@ OpenLayers.Util.destinationVincenty = function(lonlat, brng, dist) { * * 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 = ""; diff --git a/tests/Util.html b/tests/Util.html index e1476041aa..f70cbb9ddf 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -952,7 +952,16 @@ } 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 = ''");