mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
using try/catch $.parseJSON to check for JSONs
This commit is contained in:
parent
2a251b219a
commit
ce1360f5cb
@ -629,7 +629,11 @@ function processResponse( xhr ){
|
||||
data = xhr.responseText;
|
||||
}
|
||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||
data = $.parseJSON(responseText);
|
||||
try{
|
||||
data = $.parseJSON(responseText);
|
||||
} catch(e){
|
||||
data = responseText;
|
||||
}
|
||||
}else{
|
||||
data = responseText;
|
||||
}
|
||||
|
@ -2114,19 +2114,6 @@ function _getSafeElemSize (oElement) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @function
|
||||
* @private
|
||||
*/
|
||||
function _isJSON(str){
|
||||
try{
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @private
|
||||
@ -2141,8 +2128,13 @@ function getTileSourceImplementation( viewer, tileSource, imgOptions, successCal
|
||||
if ( tileSource.match( /^\s*<.*>\s*$/ ) ) {
|
||||
tileSource = $.parseXml( tileSource );
|
||||
//json should start with "{" or "[" and end with "}" or "]"
|
||||
} else if ( _isJSON(tileSource) ) {
|
||||
tileSource = $.parseJSON(tileSource);
|
||||
} else if ( tileSource.match(/^\s*[\{\[].*[\}\]]\s*$/ ) ) {
|
||||
try {
|
||||
var tileSourceJ = $.parseJSON(tileSource);
|
||||
tileSource = tileSourceJ;
|
||||
} catch (e) {
|
||||
//tileSource = tileSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user