From a8480afc83f689c4b85b18409d7dd92370075120 Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Wed, 21 Feb 2018 21:43:24 +0100 Subject: [PATCH] Fixed trailing slash bug in export url --- frontend/src/pages/reviewer/ReviewerLayout.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/reviewer/ReviewerLayout.vue b/frontend/src/pages/reviewer/ReviewerLayout.vue index af54a6ac..ea13e8d4 100644 --- a/frontend/src/pages/reviewer/ReviewerLayout.vue +++ b/frontend/src/pages/reviewer/ReviewerLayout.vue @@ -62,15 +62,19 @@ }, methods: { download () { - const url = process.env.NODE_ENV === 'production' - ? `https://${window.location.host}${window.location.pathname}/api/export/csv/` - : 'http://localhost:8000/api/export/csv/' + let url = '' + if (process.env.NODE_ENV === 'production') { + const baseUrl = `https://${window.location.host}${window.location.pathname}`.replace(/\/+$/, '') + url = `${baseUrl}/api/export/csv` + } else { + url = 'http://localhost:8000/api/export/csv/' + } ax.get(url, {responseType: 'blob'}).then(response => { console.log(response) let blob = new Blob([response.data], { type: 'text/csv' }) let url = window.URL.createObjectURL(blob) - window.open(url) // Mostly the same, I was just experimenting with different approaches, tried link.click, iframe and other solutions + window.open(url) }) } } -- GitLab