From 61c77a344078c54d3a213f9a8dab9dfe7a79d951 Mon Sep 17 00:00:00 2001 From: Aiosa Date: Sun, 21 Aug 2022 10:09:36 +0200 Subject: [PATCH] Fix hash tile generation by checking the validity of URL input parameter and fallback to level, x, y variables. --- src/tilesource.js | 11 +++++++---- src/viewer.js | 5 ----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/tilesource.js b/src/tilesource.js index cba91511..2c99db29 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -688,11 +688,14 @@ $.TileSource.prototype = { * @param {*} postData data the tile was fetched with (type depends on getTilePostData(..) return type) */ getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) { - if (ajaxHeaders) { - return url + "+" + JSON.stringify(ajaxHeaders); - } else { - return url; + function withHeaders(hash) { + return ajaxHeaders ? hash + "+" + JSON.stringify(ajaxHeaders) : hash; } + + if (typeof url !== "string") { + return withHeaders(level + "/" + x + "_" + y); + } + return withHeaders(url); }, /** diff --git a/src/viewer.js b/src/viewer.js index 007f1bf1..df553e4c 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1398,11 +1398,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, options.ajaxHeaders = $.extend({}, this.ajaxHeaders, options.ajaxHeaders); } - if (!$.isFunction(options.tileSource.getTileHashKey)) { - //silently add custom implementation - options.tileSource.getTileHashKey = $.TileSource.prototype.getTileHashKey; - } - var myQueueItem = { options: options };