export class UrlHelper { static getStaticResourceUrlFromPath ( path ) { if ( this . startsWith ( path , "data:" ) ) { return path ; } return mx . appUrl + path ; } static getStaticResourceUrl ( url ) { if ( this . startsWith ( url , "data:" ) ) { return url ; } if ( ! /^\w+:\/\// . test ( url ) ) { url = this . getStaticResourceUrlFromPath ( url ) ; } const cacheBust = mx . server . getCacheBust ( ) ; if ( this . startsWith ( url , mx . appUrl ) && ! this . endsWith ( url , cacheBust ) ) { url += ( /\?/ . test ( url ) ? "&" : "?" ) + cacheBust ; } return url ; } static getDynamicResourcePath ( guid , changedDate , isThumbnail ) { let url = "file?" + [ "guid=" + guid , "changedDate=" + changedDate ] . join ( "&" ) ; if ( isThumbnail ) { url += "&thumb=true" ; } return url ; } static getDynamicResourceUrl ( guid , changedDate , isThumbnail = false ) { return mx . remoteUrl + this . getDynamicResourcePath ( guid , changedDate , isThumbnail ) ; } private static startsWith ( searchString , prefix ) { return searchString . indexOf ( prefix ) === 0 ; } private static endsWith ( searchString , suffix ) { return searchString . indexOf ( suffix , searchString . length - suffix . length ) !== - 1 ; } }