"Create an urlAppend function that appends strings to urls and handles ? and & appropriately". r=crschmidt (closes #2297)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9730 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -628,6 +628,30 @@ OpenLayers.Util.getParameterString = function(params) {
|
||||
return paramsArray.join("&");
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: urlAppend
|
||||
* Appends a parameter string to a url. This function includes the logic for
|
||||
* using the appropriate character (none, & or ?) to append to the url before
|
||||
* appending the param string.
|
||||
*
|
||||
* Parameters:
|
||||
* url - {String} The url to append to
|
||||
* paramStr - {String} The param string to append
|
||||
*
|
||||
* Returns:
|
||||
* {String} The new url
|
||||
*/
|
||||
OpenLayers.Util.urlAppend = function(url, paramStr) {
|
||||
var newUrl = url;
|
||||
if(paramStr) {
|
||||
var parts = (url + " ").split(/[?&]/);
|
||||
newUrl += (parts.pop() === " " ?
|
||||
paramStr :
|
||||
parts.length ? "&" + paramStr : "?" + paramStr);
|
||||
}
|
||||
return newUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
* Property: ImgPath
|
||||
* {String} Default is ''.
|
||||
|
||||
Reference in New Issue
Block a user