Changeset 3317
- Timestamp:
- 06/11/07 15:28:48 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (2 diffs)
- trunk/openlayers/tests/test_Util.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Util.js
r3284 r3317 610 610 url = window.location.href; 611 611 } 612 613 var start = url.indexOf('?'); 614 var stop = url.indexOf('#'); 615 616 if (start != -1) { 617 if (stop != -1) { 618 var query = url.substring(start + 1, stop); 619 } else { 620 var query = url.substring(start + 1); 621 } 622 } else { 623 return {}; 624 } 625 612 var query = (url.indexOf('?') != -1) ? url.substring(url.indexOf('?') + 1) 613 : ''; 626 614 var args = new Object(); 627 615 pairs = query.split(/[&;]/); … … 630 618 if(keyValue.length == 2) { 631 619 args[decodeURIComponent(keyValue[0])] = 632 decodeURIComponent(keyValue[1]) || '';620 decodeURIComponent(keyValue[1]); 633 621 } 634 622 } trunk/openlayers/tests/test_Util.html
r3284 r3317 572 572 } 573 573 574 function test_Util_getArgs(t) {575 t.plan(5);576 t.eq(OpenLayers.Util.getArgs('http://www.example.com'), {}, "getArgs works when args = ''");577 t.eq(OpenLayers.Util.getArgs('http://www.example.com?'), {}, "getArgs works when args = '?'");578 t.eq(OpenLayers.Util.getArgs('http://www.example.com?hello=world&foo=bar'),579 {'hello' : 'world', 'foo': 'bar'}, "getArgs works when args = '?hello=world&foo=bar'");580 t.eq(OpenLayers.Util.getArgs('http://www.example.com?hello=&foo=bar'),581 {'hello' : '', 'foo': 'bar'}, "getArgs works when args = '?hello=&foo=bar'");582 t.eq(OpenLayers.Util.getArgs('http://www.example.com?foo=bar#bugssucks'),583 {'foo': 'bar'}, "getArgs works when using a fragment identifier");584 }585 586 574 // --> 587 575 </script>
