Thanks to a patch from greid, fix case where "" is passed into getParameters,

which would previously have weird behavior. (Pullup #3408)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@12217 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2011-08-08 13:43:14 +00:00
parent 51efcde523
commit 533f8625d9
2 changed files with 13 additions and 3 deletions

View File

@@ -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 = "";

View File

@@ -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 = ''");