[OpenLayers-Commits] r11133 - in trunk/openlayers: lib/OpenLayers
tests
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Feb 17 10:04:53 EST 2011
Author: bartvde
Date: 2011-02-17 07:04:53 -0800 (Thu, 17 Feb 2011)
New Revision: 11133
Modified:
trunk/openlayers/lib/OpenLayers/Request.js
trunk/openlayers/tests/Request.html
Log:
OpenLayers.Request issue method creates URLs such as http://service?&key=value, p=fvanderbiest, r=me (closes #3055)
Modified: trunk/openlayers/lib/OpenLayers/Request.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Request.js 2011-02-17 05:29:11 UTC (rev 11132)
+++ trunk/openlayers/lib/OpenLayers/Request.js 2011-02-17 15:04:53 UTC (rev 11133)
@@ -125,14 +125,8 @@
// create request, open, and set headers
var request = new OpenLayers.Request.XMLHttpRequest();
- var url = config.url;
- if(config.params) {
- var paramString = OpenLayers.Util.getParameterString(config.params);
- if(paramString.length > 0) {
- var separator = (url.indexOf('?') > -1) ? '&' : '?';
- url += separator + paramString;
- }
- }
+ var url = OpenLayers.Util.urlAppend(config.url,
+ OpenLayers.Util.getParameterString(config.params));
var sameOrigin = !(url.indexOf("http") == 0);
var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
if (urlParts) {
Modified: trunk/openlayers/tests/Request.html
===================================================================
--- trunk/openlayers/tests/Request.html 2011-02-17 05:29:11 UTC (rev 11132)
+++ trunk/openlayers/tests/Request.html 2011-02-17 15:04:53 UTC (rev 11133)
@@ -20,7 +20,7 @@
function test_issue(t) {
setup();
- t.plan(21);
+ t.plan(22);
var request, config;
var proto = OpenLayers.Request.XMLHttpRequest.prototype;
var issue = OpenLayers.Function.bind(OpenLayers.Request.issue,
@@ -81,7 +81,18 @@
t.eq(url, config.url + "&foo=bar", "existing query string gets extended with &");
}
request = issue(config);
-
+
+ // test that query string doesn't get ? followed by &
+ config = {
+ method: "GET",
+ url: "http://example.com/service?",
+ params: {"foo": "bar"}
+ };
+ proto.open = function(method, url, async, user, password) {
+ t.eq(url, config.url + "foo=bar", "existing query string ending with ? gets extended without &");
+ }
+ request = issue(config);
+
// reset open method
proto.open = _open;
More information about the Commits
mailing list