Changeset 10071


Ignore:
Timestamp:
Feb 16, 2010 10:59:49 PM (6 years ago)
Author:
fredj
Message:

OpenLayers.Util.getParameters: decodeURIComponent the keys, not only the values. r=elemoine (closes #2327)

Location:
trunk/openlayers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openlayers/lib/OpenLayers/Util.js

    r10019 r10071  
    981981
    982982            //decode individual values
    983             value = value.split(",");
    984             for(var j=0, jlen=value.length; j<jlen; j++) {
    985                 value[j] = decodeURIComponent(value[j]);
    986             }
     983            value = decodeURIComponent(value).split(",");
    987984
    988985            //if there's only one value, do not return as array                   
  • trunk/openlayers/tests/Util.html

    r10019 r10071  
    893893
    894894    function test_Util_getParameters(t) {
    895         t.plan(6);
     895        t.plan(8);
    896896
    897897        t.eq(OpenLayers.Util.getParameters('http://www.example.com'), {},
     
    908908             {'foo': 'bar'},
    909909             "getParameters works when using a fragment identifier");
    910         t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar,pub,disco'),
    911              {'foo': ['bar', 'pub', 'disco']},
     910        t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar%3Aone'),
     911             {'foo': 'bar:one'},
     912             "getParameters works with percent encoded values");
     913        t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar:one,pub,disco'),
     914             {'foo': ['bar:one', 'pub', 'disco']},
    912915             "getParameters works with a comma-separated value (parses into array)");
     916        t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar%3Aone%2Cpub%2Cdisco'),
     917             {'foo': ['bar:one', 'pub', 'disco']},
     918             "getParameters works with a URL encoded comma-separated values (parses into array)");
    913919    }
    914920
Note: See TracChangeset for help on using the changeset viewer.