ultisuite-client/lib/drive/docs-export-download.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

24 lines
725 B
TypeScript

export function downloadBlob(blob: Blob, fileName: string) {
const url = URL.createObjectURL(blob)
const anchor = document.createElement("a")
anchor.href = url
anchor.download = fileName
anchor.click()
URL.revokeObjectURL(url)
}
function baseNameWithoutExt(fileName: string): string {
const slash = fileName.lastIndexOf("/")
const base = slash >= 0 ? fileName.slice(slash + 1) : fileName
const dot = base.lastIndexOf(".")
return dot > 0 ? base.slice(0, dot) : base
}
export function exportFileName(sourceName: string, ext: string): string {
return `${baseNameWithoutExt(sourceName)}.${ext}`
}
export function baseNameFromSource(sourceName: string): string {
return baseNameWithoutExt(sourceName)
}