export function getFilenameFromContentDisposition ( contentDisposition , defaultFilename = 'download' ) { const re = /^attachment;\s*filename="(.*)"/ ; const matches = re . exec ( contentDisposition ) ; let filename = defaultFilename ; if ( matches ) { const [ , name ] = matches ; if ( name ) { filename = name ; } } return filename ; } export function triggerDownload ( objectUrl , filename ) { const link = document . createElement ( 'a' ) ; link . href = objectUrl ; link . download = escape ( filename ) ; const parent = document . body ; parent . appendChild ( link ) ; link . click ( ) ; parent . removeChild ( link ) ; }