We are dealing with strings for comparison
Because OpenLayers.Util.getParameters turns comma delimited values into arrays, comparing e.g. bbox values in urls will return false. By introducing a splitArgs option, we can use getParameters in a way that leaves such values as strings and makes them comparable in OpenLayers.Util.isEquivalentUrl.
This commit is contained in:
committed by
Bart van den Eijnden
parent
7c5afe1acf
commit
8b4592e71a
+16
-4
@@ -866,11 +866,17 @@ OpenLayers.Util.destinationVincenty = function(lonlat, brng, dist) {
|
||||
* url - {String} Optional url used to extract the query string.
|
||||
* If url is null or is not supplied, query string is taken
|
||||
* from the page location.
|
||||
* options - {Object} Additional options. Optional.
|
||||
*
|
||||
* Valid options:
|
||||
* splitArgs - {Boolean} Split comma delimited params into arrays? Default is
|
||||
* true.
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An object of key/value pairs from the query string.
|
||||
*/
|
||||
OpenLayers.Util.getParameters = function(url) {
|
||||
OpenLayers.Util.getParameters = function(url, options) {
|
||||
options = options || {};
|
||||
// if no url specified, take it from the location bar
|
||||
url = (url === null || url === undefined) ? window.location.href : url;
|
||||
|
||||
@@ -906,7 +912,9 @@ OpenLayers.Util.getParameters = function(url) {
|
||||
}
|
||||
|
||||
// follow OGC convention of comma delimited values
|
||||
value = value.split(",");
|
||||
if (options.splitArgs !== false) {
|
||||
value = value.split(",");
|
||||
}
|
||||
|
||||
//if there's only one value, do not return as array
|
||||
if (value.length == 1) {
|
||||
@@ -1299,7 +1307,8 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
|
||||
OpenLayers.Util.applyDefaults(options, {
|
||||
ignoreCase: true,
|
||||
ignorePort80: true,
|
||||
ignoreHash: true
|
||||
ignoreHash: true,
|
||||
splitArgs: false
|
||||
});
|
||||
|
||||
var urlObj1 = OpenLayers.Util.createUrlObject(url1, options);
|
||||
@@ -1340,6 +1349,8 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
|
||||
* ignoreCase - {Boolean} lowercase url,
|
||||
* ignorePort80 - {Boolean} don't include explicit port if port is 80,
|
||||
* ignoreHash - {Boolean} Don't include part of url after the hash (#).
|
||||
* splitArgs - {Boolean} Split comma delimited params into arrays? Default is
|
||||
* true.
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An object with separate url, a, port, host, and args parsed out
|
||||
@@ -1395,7 +1406,8 @@ OpenLayers.Util.createUrlObject = function(url, options) {
|
||||
var qMark = url.indexOf("?");
|
||||
queryString = (qMark != -1) ? url.substr(qMark) : "";
|
||||
}
|
||||
urlObject.args = OpenLayers.Util.getParameters(queryString);
|
||||
urlObject.args = OpenLayers.Util.getParameters(queryString,
|
||||
{splitArgs: options.splitArgs});
|
||||
|
||||
// pathname
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user