mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Merge pull request #835 from gaetano-guerriero/fix/dzi-auto-tiles-url
fixed dzitilesource guessing of tilesUrl.
This commit is contained in:
commit
2f8bb4fbf5
@ -139,7 +139,8 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead
|
||||
}
|
||||
|
||||
if (url && !options.tilesUrl) {
|
||||
options.tilesUrl = url.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/, '$1_files/');
|
||||
options.tilesUrl = url.replace(
|
||||
/([^\/]+?)(\.(dzi|xml|js))?\/?(\?.*)?$/, '$1_files/');
|
||||
|
||||
if (url.search(/\.(dzi|xml|js)\?/) != -1) {
|
||||
options.queryParams = url.match(/\?.*/);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -73,6 +73,7 @@
|
||||
<script src="/test/modules/tilecache.js"></script>
|
||||
<script src="/test/modules/referencestrip.js"></script>
|
||||
<script src="/test/modules/tilesource.js"></script>
|
||||
<script src="/test/modules/dzitilesource.js"></script>
|
||||
<script src="/test/modules/tilesourcecollection.js"></script>
|
||||
<script src="/test/modules/spring.js"></script>
|
||||
<script src="/test/modules/rectangle.js"></script>
|
||||
|
38
test/modules/dzitilesource.js
Normal file
38
test/modules/dzitilesource.js
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
/*global module:true, test:true, equal:true, OpenSeadragon:true*/
|
||||
|
||||
(function() {
|
||||
|
||||
module('DziTileSource', {
|
||||
setup: function() {
|
||||
testLog.reset();
|
||||
}
|
||||
});
|
||||
|
||||
function testImplicitTilesUrl(dziUrl, expected, msg) {
|
||||
var source = new OpenSeadragon.DziTileSource();
|
||||
var options = source.configure({
|
||||
Image: {Size: {Width:0, Height: 0}}
|
||||
}, dziUrl);
|
||||
equal(options.tilesUrl, expected, msg);
|
||||
}
|
||||
|
||||
test('test implicit tilesUrl guessed from dzi url', function() {
|
||||
testImplicitTilesUrl(
|
||||
'/path/my.dzi', '/path/my_files/',
|
||||
'dzi extension should be stripped');
|
||||
testImplicitTilesUrl(
|
||||
'/path/my', '/path/my_files/',
|
||||
'no extension should still produce _files path');
|
||||
testImplicitTilesUrl(
|
||||
'/my/', '/my_files/',
|
||||
'no extension with trailing slash should preserve slash');
|
||||
testImplicitTilesUrl(
|
||||
'my.xml', 'my_files/',
|
||||
'relative link should stay the same');
|
||||
testImplicitTilesUrl(
|
||||
'/p/foo.dzi?a=1&b=2', '/p/foo_files/',
|
||||
'querystring in dzi url should be ignored');
|
||||
});
|
||||
|
||||
}());
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -37,6 +37,7 @@
|
||||
<script src="/test/modules/tilecache.js"></script>
|
||||
<script src="/test/modules/referencestrip.js"></script>
|
||||
<script src="/test/modules/tilesource.js"></script>
|
||||
<script src="/test/modules/dzitilesource.js"></script>
|
||||
<script src="/test/modules/tilesourcecollection.js"></script>
|
||||
<script src="/test/modules/spring.js"></script>
|
||||
<script src="/test/modules/rectangle.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user