diff --git a/src/modules/views/Folder/createFileOpeningHandler.js b/src/modules/views/Folder/createFileOpeningHandler.js index e7a4986337..4b4132c5bf 100644 --- a/src/modules/views/Folder/createFileOpeningHandler.js +++ b/src/modules/views/Folder/createFileOpeningHandler.js @@ -35,7 +35,12 @@ const createFileOpeningHandler = Alerter.error('alert.could_not_open_file') } } else { - const url = generateShortcutUrl({ file, client, isFlatDomain }) + const url = generateShortcutUrl({ + file, + client, + isFlatDomain, + fromPublicFolder + }) openInNewTab(url) } } else if (isNote) { diff --git a/src/modules/views/Folder/generateShortcutUrl.js b/src/modules/views/Folder/generateShortcutUrl.js index df5a7124f5..d84e4952c1 100644 --- a/src/modules/views/Folder/generateShortcutUrl.js +++ b/src/modules/views/Folder/generateShortcutUrl.js @@ -1,12 +1,17 @@ import { generateWebLink } from 'cozy-client' -const generateShortcutUrl = ({ file, client, isFlatDomain }) => { +const generateShortcutUrl = ({ + file, + client, + isFlatDomain, + fromPublicFolder +}) => { const currentURL = new URL(window.location) let webLink = '' - if (currentURL.pathname === '/public') { + if (fromPublicFolder) { webLink = generateWebLink({ cozyUrl: client.getStackClient().uri, - pathname: '/public', + pathname: currentURL.pathname, slug: 'drive', hash: `external/${file.id}`, searchParams: currentURL.searchParams,