mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-07-02 20:32:58 +00:00
* fix(files): navigate signed CDN downloads * fix(files): avoid popup target for signed downloads * test(files): restore download URL mock
15 lines
505 B
TypeScript
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);
|
|
}
|
|
}
|