mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
added fix for supporting weird filenames that look like JSONs
This commit is contained in:
parent
b941864ac5
commit
2a251b219a
@ -2113,6 +2113,20 @@ function _getSafeElemSize (oElement) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function _isJSON(str){
|
||||||
|
try{
|
||||||
|
JSON.parse(str);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
@ -2127,7 +2141,7 @@ function getTileSourceImplementation( viewer, tileSource, imgOptions, successCal
|
|||||||
if ( tileSource.match( /^\s*<.*>\s*$/ ) ) {
|
if ( tileSource.match( /^\s*<.*>\s*$/ ) ) {
|
||||||
tileSource = $.parseXml( tileSource );
|
tileSource = $.parseXml( tileSource );
|
||||||
//json should start with "{" or "[" and end with "}" or "]"
|
//json should start with "{" or "[" and end with "}" or "]"
|
||||||
} else if ( tileSource.match(/^\s*[\{\[].*[\}\]]\s*$/ ) ) {
|
} else if ( _isJSON(tileSource) ) {
|
||||||
tileSource = $.parseJSON(tileSource);
|
tileSource = $.parseJSON(tileSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user