@@ -3807,12 +3807,16 @@ function parseConfig(configData, urlOnLayers) {
38073807 // recurse through a STAC layer building sublayers
38083808 function getSTACLayers ( d ) {
38093809 let stac_data
3810- const urlPieces = d . url . split ( ':' )
3811- const prefix = urlPieces . length > 1 ? urlPieces [ 0 ] : ''
3812- const url =
3813- urlPieces . length > 1 ? urlPieces . slice ( 1 ) . join ( ':' ) : urlPieces [ 0 ]
3810+ const stacRegex =
3811+ / ^ (?< prefix > s t a c ( - ( ( i t e m ) | ( c a t a l o g ) | ( c o l l e c t i o n ) ) ) ? : ) ? (?< url > .* ) / i
3812+ const urlMatch = d . url . match ( stacRegex )
3813+ if ( ! urlMatch ) {
3814+ console . warn ( 'Could not process STAC URL' )
3815+ return d
3816+ }
3817+ const { prefix, url } = urlMatch . groups
38143818 d . url = url // replace the current URL so we no longer need to worry about the special prefix
3815- if ( prefix !== 'stac-item' ) {
3819+ if ( prefix !== 'stac-item: ' ) {
38163820 $ . ajax ( {
38173821 url : L_ . getUrl ( 'stac' , d . url , d ) ,
38183822 success : ( resp ) => {
@@ -3834,9 +3838,9 @@ function parseConfig(configData, urlOnLayers) {
38343838 getSTACLayers (
38353839 Object . assign ( { } , d , {
38363840 url : children [ i ] . href . replace ( './' , `${ path } /` ) ,
3837- display_name : children [ i ] . title || F_ . fileNameFromPath (
3838- children [ i ] . href
3839- ) ,
3841+ display_name :
3842+ children [ i ] . title ||
3843+ F_ . fileNameFromPath ( children [ i ] . href ) ,
38403844 uuid : uuid ,
38413845 name : uuid ,
38423846 } )
@@ -3871,7 +3875,9 @@ function parseConfig(configData, urlOnLayers) {
38713875 // we shouldn't need to pre-fetch item data
38723876 Object . assign ( { } , d , {
38733877 url : items [ i ] . href . replace ( './' , `${ path } /` ) ,
3874- display_name : items [ i ] . title || F_ . fileNameFromPath ( items [ i ] . href ) ,
3878+ display_name :
3879+ items [ i ] . title ||
3880+ F_ . fileNameFromPath ( items [ i ] . href ) ,
38753881 uuid : uuid ,
38763882 name : uuid ,
38773883 } )
0 commit comments