Skip to content

Commit

Permalink
Send auth header to same host, always open download in new window
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Sep 6, 2023
1 parent 933415f commit 366e9d7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/formats/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export class Format {
tempLink.style.display = 'none';
tempLink.href = this.getUrl();
tempLink.setAttribute('download', filename ? filename : Utils.makeFileName("result", this.type));
if (typeof tempLink.download === 'undefined') {
tempLink.setAttribute('target', '_blank');
}
tempLink.setAttribute('target', '_blank');
document.body.appendChild(tempLink);
tempLink.click();
document.body.removeChild(tempLink);
Expand Down Expand Up @@ -62,7 +60,14 @@ export class Format {
blob = await response.blob();
}
else {
blob = await connection.download(url, false);
let auth = false;
try {
let apiUrl = new URL(connection.getUrl());
let requestUrl = new URL(url);
auth = apiUrl.origin === requestUrl.origin;
} catch (error) {}

blob = await connection.download(url, auth);
}
let promise = new Promise((resolve, reject) => {
let reader = new FileReader();
Expand Down

0 comments on commit 366e9d7

Please sign in to comment.