Use regular expression instead of String#endsWith() check
This commit is contained in:
@@ -2,7 +2,6 @@ goog.provide('ol.source.TileArcGISRest');
|
|||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('goog.string');
|
|
||||||
goog.require('goog.uri.utils');
|
goog.require('goog.uri.utils');
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
@@ -109,20 +108,13 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize
|
|||||||
url = urls[index];
|
url = urls[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!goog.string.endsWith(url, '/')) {
|
var modifiedUrl = url
|
||||||
url = url + '/';
|
.replace(/MapServer\/?$/, 'MapServer/export')
|
||||||
}
|
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
|
||||||
|
if (modifiedUrl == url) {
|
||||||
// If a MapServer, use export. If an ImageServer, use exportImage.
|
|
||||||
if (goog.string.endsWith(url, 'MapServer/')) {
|
|
||||||
url = url + 'export';
|
|
||||||
} else if (goog.string.endsWith(url, 'ImageServer/')) {
|
|
||||||
url = url + 'exportImage';
|
|
||||||
} else {
|
|
||||||
goog.asserts.fail('Unknown Rest Service', url);
|
goog.asserts.fail('Unknown Rest Service', url);
|
||||||
}
|
}
|
||||||
|
return goog.uri.utils.appendParamsFromMap(modifiedUrl, params);
|
||||||
return goog.uri.utils.appendParamsFromMap(url, params);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user