OpenLayers.Request issue method creates URLs such as http://service?&key=value, p=fvanderbiest, r=me (closes #3055)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11133 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-02-17 15:04:53 +00:00
parent 0781655e19
commit 04acbeeb0e
2 changed files with 15 additions and 10 deletions

View File

@@ -125,14 +125,8 @@ OpenLayers.Request = {
// 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) {

View File

@@ -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;