OpenLayers OpenLayers

Ticket #491: 491.patch

File 491.patch, 1.6 kB (added by crschmidt, 2 years ago)
  • Util.js

    old new  
    377387* @returns a concatenation of the properties of an object in  
    378388*    http parameter notation.  
    379389*    (ex. <i>"key1=value1&key2=value2&key3=value3"</i>) 
     390*    If a parameter is actually a list, that parameter will then 
     391*    be set to a comma-seperated list of values (foo,bar) instead 
     392*    of being URL escaped (foo%3Abar).  
    380393* @type String 
    381394*/ 
    382395OpenLayers.Util.getParameterString = function(params) { 
    383396    paramsArray = new Array(); 
    384397     
    385398    for (var key in params) { 
    386         var value = params[key]; 
    387         if ((value != null) && (typeof value != 'function')) { 
    388             paramsArray.push(encodeURIComponent(key) + "=" + 
    389                              encodeURIComponent(value)); 
     399      var value = params[key]; 
     400      if ((value != null) && (typeof value != 'function')) { 
     401        var encodedValue; 
     402        if (typeof value == 'object' && value.constructor == Array) { 
     403          /* value is an array; encode items and separate with "," */ 
     404          var encodedItemArray = new Array(); 
     405          for (var itemIndex=0; itemIndex<value.length; itemIndex++) { 
     406            encodedItemArray.push(encodeURIComponent(value[itemIndex])); 
     407          } 
     408          encodedValue = encodedItemArray.join(","); 
    390409        } 
     410        else { 
     411          /* value is a string; simply encode */ 
     412          encodedValue = encodeURIComponent(value); 
     413        } 
     414        paramsArray.push(encodeURIComponent(key) + "=" + encodedValue); 
     415      } 
    391416    } 
    392417     
    393418    return paramsArray.join("&");