From 1d06490b2c6ed2c31ecfb6b84518740ecec1a99e Mon Sep 17 00:00:00 2001 From: crschmidt Date: Fri, 16 Feb 2007 20:38:00 +0000 Subject: [PATCH] Change the encoding of parameters, as discussed in #491. The reason this is important is that the WMS spec specifies that you should seperate layer names with a ",", and we were encoding that, so compliant WMSes would attempt to find a single layer with ","s in the name, instead of grabbing multiple layers. The new way to specify multiple layers is to set: layers: ['global_modis','landsat'] or the like. Includes tests, signoff from SDE. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2232 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 23 +++++++++++++++++++---- tests/test_Util.html | 11 ++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index edf3522595..61fb25cf3b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -394,17 +394,32 @@ OpenLayers.Util.applyDefaults = function (to, from) { * @returns a concatenation of the properties of an object in * http parameter notation. * (ex. "key1=value1&key2=value2&key3=value3") +* If a parameter is actually a list, that parameter will then +* be set to a comma-seperated list of values (foo,bar) instead +* of being URL escaped (foo%3Abar). * @type String */ OpenLayers.Util.getParameterString = function(params) { paramsArray = new Array(); for (var key in params) { - var value = params[key]; - if ((value != null) && (typeof value != 'function')) { - paramsArray.push(encodeURIComponent(key) + "=" + - encodeURIComponent(value)); + var value = params[key]; + if ((value != null) && (typeof value != 'function')) { + var encodedValue; + if (typeof value == 'object' && value.constructor == Array) { + /* value is an array; encode items and separate with "," */ + var encodedItemArray = new Array(); + for (var itemIndex=0; itemIndex