Skip to content

Commit

Permalink
Merge pull request #227 from devgateway/fix/OCE-159/ie-download-worka…
Browse files Browse the repository at this point in the history
…round

OCE-159 Now using the Safari redirect workaround for both Safari and IE
  • Loading branch information
mpostelnicu authored Dec 13, 2016
2 parents bc88e49 + 4c5efa2 commit 1344233
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ui/oce/tools.es6
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ export const send = url => fetch(url.clone().query(""), {
body: url.query()
});

export let download = ({ep, filters, years, t}) =>
send(new URI(`/api/ocds/${ep}`)
.addSearch(filters.toJS())
.addSearch('year', years.toArray())
//this sin shall be atoned for in the future
.addSearch('language', localStorage.oceLocale)
).then(response => {
export let download = ({ep, filters, years, t}) => {
const url = new URI(`/api/ocds/${ep}`)
.addSearch(filters.toJS())
.addSearch('year', years.toArray())
//this sin shall be atoned for in the future
.addSearch('language', localStorage.oceLocale);
return send(url).then(response => {
let {userAgent} = navigator;
let isSafari = -1 < userAgent.indexOf("Safari") && -1 == userAgent.indexOf("Chrom");//excludes both Chrome and Chromium
if(isSafari){
let isSafari = -1 < userAgent.indexOf("Safari") && -1 == userAgent.indexOf("Chrom");//excludes both Chrome and Chromium
const isIE = navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/)
|| navigator.userAgent.match(/rv 11/)) || $.browser.msie == 1;
if (isSafari || isIE) {
location.href = url;
return response;
}
Expand All @@ -79,6 +81,7 @@ export let download = ({ep, filters, years, t}) =>
}).catch(() => {
alert(t('export:error'));
});
};

export const shallowCopy = original => {
let copy = {};
Expand Down

0 comments on commit 1344233

Please sign in to comment.