Skip to content

Commit

Permalink
fix: add workaround for wrong config file extension on some browsers (#…
Browse files Browse the repository at this point in the history
…638)

* fix file extension on some browsers

* remove charset as its unsued according to the standard
  • Loading branch information
t-aleksander authored Jun 3, 2024
1 parent f3eb358 commit 6acd5a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion web/src/shared/utils/downloadWGConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import saveAs from 'file-saver';

export const downloadWGConfig = (config: string, fileName: string) => {
const blob = new Blob([config.replace(/^[^\S\r\n]+|[^\S\r\n]+$/gm, '')], {
type: 'text/plain;charset=utf-8',
// octet-stream is used here as a workaround: some browsers will append
// an additional .txt extension to the file name if the MIME type is text/plain.
type: 'application/octet-stream',
});
saveAs(blob, `${fileName.toLowerCase()}.conf`);
};

0 comments on commit 6acd5a7

Please sign in to comment.