import { CoreSetup } from 'opensearch-dashboards/public' ; import { getUrlIdFromGotoRoute , getUrlPath , GOTO_PREFIX } from '../../common/short_url_routes' ; export const createShortUrlRedirectApp = ( core , location ) => ( { id : 'short_url_redirect' , appRoute : GOTO_PREFIX , chromeless : true , title : 'Short URL Redirect' , async mount ( ) { const urlId = getUrlIdFromGotoRoute ( location . pathname ) ; if ( ! urlId ) { throw new Error ( 'Url id not present in path' ) ; } const response = await core . http . get < { url : string ; } > ( getUrlPath ( urlId ) ) ; const redirectUrl = response . url ; const { hashUrl } = await import ( '../../../opensearch_dashboards_utils/public' ) ; const hashedUrl = hashUrl ( redirectUrl ) ; const url = core . http . basePath . prepend ( hashedUrl ) ; location . href = url ; return ( ) => { } ; } , } ) ;