mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +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;
|
data = xhr.responseText;
|
||||||
}
|
}
|
||||||
}else if( responseText.match(/\s*[\{\[].*/) ){
|
}else if( responseText.match(/\s*[\{\[].*/) ){
|
||||||
data = $.parseJSON(responseText);
|
try{
|
||||||
|
data = $.parseJSON(responseText);
|
||||||
|
} catch(e){
|
||||||
|
data = responseText;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
data = responseText;
|
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
|
* @function
|
||||||
* @private
|
* @private
|
||||||
@ -2141,8 +2128,13 @@ 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 ( _isJSON(tileSource) ) {
|
} else if ( tileSource.match(/^\s*[\{\[].*[\}\]]\s*$/ ) ) {
|
||||||
tileSource = $.parseJSON(tileSource);
|
try {
|
||||||
|
var tileSourceJ = $.parseJSON(tileSource);
|
||||||
|
tileSource = tileSourceJ;
|
||||||
|
} catch (e) {
|
||||||
|
//tileSource = tileSource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user