interface Named { name : string ; } export function compareName ( a , b ) { return a . name . localeCompare ( b . name ) ; } example export function titleizeImageryName ( name ) { return ( name [ 0 ] . toUpperCase ( ) + name . slice ( 1 ) . replace ( /_(\d+)-(\d+)m/g , ' $1.$2m' ) . replace ( /_/g , ' ' ) ) ; } example param name return export function extractYearRangeFromName ( name ) { const re = /(?:^|\D)(\d{4})(?:-(\d{2}))?(?:$|\D)/g ; const years = [ ] ; for ( let m = re . exec ( name ) ; m != null ; m = re . exec ( name ) ) { years . push ( parseInt ( m [ 1 ] ) ) ; if ( m [ 2 ] != null ) years . push ( parseInt ( m [ 1 ] . slice ( 0 , 2 ) + m [ 2 ] ) ) ; } if ( years . length === 0 ) { return [ - 1 , - 1 ] ; } years . sort ( ) ; return [ years [ 0 ] , years [ years . length - 1 ] + 1 ] ; } export function s3ToVsis3 ( name ) { return name . startsWith ( 's3://' ) ? '/vsis3/' + name . slice ( 's3://' . length ) : name ; } /** Extract the hostname from a url */ export function getUrlHost ( ref ) { if ( ref == null ) return ref ; try { const { hostname } = new URL ( ref ) ; if ( hostname == null ) return ref ; if ( hostname . startsWith ( 'www.' ) ) return hostname . slice ( 4 ) ; return hostname ; } catch ( e ) { } return ref ; }