added fix for supporting weird filenames that look like JSONs

This commit is contained in:
Ganesh Iyer 2017-05-09 14:55:23 -04:00
parent b941864ac5
commit 2a251b219a

View File

@ -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);
} }
} }