Skip to content

Commit 0ad23f2

Browse files
committed
Preserve web download line endings
1 parent 78ad6ab commit 0ad23f2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

packages/core-ui/js/gui_components/shared/download.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ class Download {
2323
return false;
2424
}
2525

26-
const blob = new this.BlobCtor([text], { type: mimeType });
26+
const blob = new this.BlobCtor([text], {
27+
type: mimeType,
28+
endings: 'transparent',
29+
});
2730
const url = this.URLObj.createObjectURL(blob);
2831
const element = this.documentObj.createElement('a');
2932
element.setAttribute('href', url);

packages/core-ui/src/tests/utils/download.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ describe('Download', () => {
3535

3636
download.downloadFile('hello world');
3737

38-
expect(BlobCtor).toHaveBeenCalledWith(['hello world'], { type: 'text/plain;charset=utf-8' });
38+
expect(BlobCtor).toHaveBeenCalledWith(['hello world'], {
39+
type: 'text/plain;charset=utf-8',
40+
endings: 'transparent',
41+
});
3942
expect(URLObj.createObjectURL).toHaveBeenCalledTimes(1);
4043
expect(appendSpy).toHaveBeenCalledTimes(1);
4144
const anchor = appendSpy.mock.calls[0][0];
@@ -91,6 +94,7 @@ describe('Download', () => {
9194

9295
expect(ownerWindowObj.Blob).toHaveBeenCalledWith(['owner-window-text'], {
9396
type: 'text/plain;charset=utf-8',
97+
endings: 'transparent',
9498
});
9599
expect(ownerWindowObj.URL.createObjectURL).toHaveBeenCalledTimes(1);
96100
expect(global.URL.createObjectURL).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)