Changeset 3284
- Timestamp:
- 06/07/07 14:32:10 (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
r3086 r3284 610 610 url = window.location.href; 611 611 } 612 var query = (url.indexOf('?') != -1) ? url.substring(url.indexOf('?') + 1) 613 : ''; 614 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 615 626 var args = new Object(); 616 627 pairs = query.split(/[&;]/); … … 619 630 if(keyValue.length == 2) { 620 631 args[decodeURIComponent(keyValue[0])] = 621 decodeURIComponent(keyValue[1]) ;632 decodeURIComponent(keyValue[1]) || ''; 622 633 } 623 634 } trunk/openlayers/tests/test_Util.html
r2645 r3284 571 571 t.eq(OpenLayers.Util.createDiv().id, "OpenLayersDiv3", "Div created is sequential, starting at lastSeqID in Util."); 572 572 } 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 573 586 // --> 574 587 </script>
