LibreChat/client/src/utils/downloadFile.ts
Danny Avila 8f92ec012c
🧭 fix: Navigate Signed CDN Downloads (#12998)
* fix(files): navigate signed CDN downloads

* fix(files): avoid popup target for signed downloads

* test(files): restore download URL mock
2026-05-07 13:36:57 -04:00

15 lines
505 B
TypeScript

export const isHttpDownloadTarget = (target?: string | null): boolean =>
/^https?:\/\//i.test(target ?? '');
export function triggerDownload(target: string, filename: string): void {
const isBlob = target.startsWith('blob:');
const link = document.createElement('a');
link.href = target;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
if (isBlob) {
setTimeout(() => URL.revokeObjectURL(target), 1000);
}
}