Skip to content

Commit 2d25bf7

Browse files
committed
fix file extension on some browsers
1 parent 5271e76 commit 2d25bf7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

web/src/shared/utils/downloadWGConfig.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import saveAs from 'file-saver';
22

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

0 commit comments

Comments
 (0)