mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-28 03:48:23 +03:00
18 lines
554 B
TypeScript
18 lines
554 B
TypeScript
|
export const saveUrl = ({ document }: Window, url: string, filename: string) => {
|
||
|
const link = document.createElement('a');
|
||
|
|
||
|
link.setAttribute('href', url);
|
||
|
link.setAttribute('download', filename);
|
||
|
link.style.visibility = 'hidden';
|
||
|
document.body.appendChild(link);
|
||
|
link.click();
|
||
|
document.body.removeChild(link);
|
||
|
};
|
||
|
|
||
|
export const saveCsv = (window: Window, csv: string, filename: string) => {
|
||
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
||
|
const url = URL.createObjectURL(blob);
|
||
|
|
||
|
saveUrl(window, url, filename);
|
||
|
};
|