it was already revoking

This commit is contained in:
Manav Rathi
2025-05-13 11:36:00 +05:30
parent e35b4eac40
commit 08346e5bcd

View File

@@ -3,11 +3,12 @@
* folder by appending a temporary <a> element to the DOM.
*
* @param url The URL that we want to download. See also
* {@link downloadAndRevokeObjectURL} and {@link downloadString}.
* {@link downloadAndRevokeObjectURL} and {@link downloadString}. The URL is
* revoked after initiating the download.
*
* @param fileName The name of downloaded file.
*/
export const downloadURL = (url: string, fileName: string) => {
export const downloadAndRevokeObjectURL = (url: string, fileName: string) => {
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
@@ -18,15 +19,6 @@ export const downloadURL = (url: string, fileName: string) => {
a.remove();
};
/**
* A variant of {@link downloadURL} that also revokes the provided
* {@link objectURL} after initiating the download.
*/
export const downloadAndRevokeObjectURL = (url: string, fileName: string) => {
downloadURL(url, fileName);
URL.revokeObjectURL(url);
};
/**
* Save the given string {@link s} as a file in the user's download folder.
*