This pull request implements a simple polyfill to get around a restriction of a[download] links, which is that they can't download files from a different origin. To get around this, we fetch the href, read it as a blob, generate a URL to the blob, and then use this as the link href with the download attribute set. Because the blob is treated as a same-origin resource, the download is allowed to proceed.
For users without JS, this will be a progressive enhancement, since the href will continue to open in a new tab within the browser (rather than being downloaded).
This pull request implements a simple polyfill to get around a restriction of
a[download]
links, which is that they can't download files from a different origin. To get around this, wefetch
the href, read it as a blob, generate a URL to the blob, and then use this as the link href with the download attribute set. Because the blob is treated as a same-origin resource, the download is allowed to proceed.For users without JS, this will be a progressive enhancement, since the href will continue to open in a new tab within the browser (rather than being downloaded).
https://user-images.githubusercontent.com/292020/226475767-9bb953f5-c21b-457c-9f68-cb002e22a07b.mp4