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:
@@ -125,14 +125,8 @@ OpenLayers.Request = {
|
|||||||
|
|
||||||
// create request, open, and set headers
|
// create request, open, and set headers
|
||||||
var request = new OpenLayers.Request.XMLHttpRequest();
|
var request = new OpenLayers.Request.XMLHttpRequest();
|
||||||
var url = config.url;
|
var url = OpenLayers.Util.urlAppend(config.url,
|
||||||
if(config.params) {
|
OpenLayers.Util.getParameterString(config.params));
|
||||||
var paramString = OpenLayers.Util.getParameterString(config.params);
|
|
||||||
if(paramString.length > 0) {
|
|
||||||
var separator = (url.indexOf('?') > -1) ? '&' : '?';
|
|
||||||
url += separator + paramString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var sameOrigin = !(url.indexOf("http") == 0);
|
var sameOrigin = !(url.indexOf("http") == 0);
|
||||||
var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
|
var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
|
||||||
if (urlParts) {
|
if (urlParts) {
|
||||||
|
|||||||
+12
-1
@@ -20,7 +20,7 @@
|
|||||||
function test_issue(t) {
|
function test_issue(t) {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
t.plan(21);
|
t.plan(22);
|
||||||
var request, config;
|
var request, config;
|
||||||
var proto = OpenLayers.Request.XMLHttpRequest.prototype;
|
var proto = OpenLayers.Request.XMLHttpRequest.prototype;
|
||||||
var issue = OpenLayers.Function.bind(OpenLayers.Request.issue,
|
var issue = OpenLayers.Function.bind(OpenLayers.Request.issue,
|
||||||
@@ -82,6 +82,17 @@
|
|||||||
}
|
}
|
||||||
request = issue(config);
|
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
|
// reset open method
|
||||||
proto.open = _open;
|
proto.open = _open;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user