From 9d97f6554c81391ae454e4f2cc48a60a328faaae Mon Sep 17 00:00:00 2001 From: mozafar Date: Mon, 28 Aug 2023 11:57:24 +0100 Subject: [PATCH] fix: remove extra slash in download links --- src/components/DownloadAs/use-hrefs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/DownloadAs/use-hrefs.js b/src/components/DownloadAs/use-hrefs.js index 180a0f23..94915707 100644 --- a/src/components/DownloadAs/use-hrefs.js +++ b/src/components/DownloadAs/use-hrefs.js @@ -7,8 +7,11 @@ const useHrefs = ({ endpoint, fileTypes, queryStr }) => { // based on query params, but older endpoints only take a timestamp queryStr = queryStr || `t=${timestamp}` + // removing leading slash for endpoint to make sure it works whether it's configured with slash or not + const endpointUrl = `${baseUrl}/api/${apiVersion}/${endpoint?.replace(/^\//, '')}` + return fileTypes.reduce((acc, type) => { - const downloadUrl = `${baseUrl}/api/${apiVersion}/${endpoint}.${type}?${queryStr}` + const downloadUrl = `${endpointUrl}.${type}?${queryStr}` acc[type] = downloadUrl return acc }, {})