From b8d12f0a51ddb79cd32a10d5027f97f253ac1d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Fern=C3=A1ndez=20de=20Alba?= <sneridagh@gmail.com> Date: Sat, 7 Dec 2024 20:39:06 +0100 Subject: [PATCH] Fixes ICS download in non-public event content (#6497) --- news/6497.bugfix | 1 + src/components/theme/EventDetails/EventDetails.jsx | 4 ++-- .../EventDetails/__snapshots__/EventDetails.test.jsx.snap | 6 +++--- .../theme/View/__snapshots__/EventView.test.jsx.snap | 6 +++--- src/express-middleware/files.js | 5 ++++- 5 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 news/6497.bugfix diff --git a/news/6497.bugfix b/news/6497.bugfix new file mode 100644 index 0000000000..c55ab658d9 --- /dev/null +++ b/news/6497.bugfix @@ -0,0 +1 @@ +Fixes ICS download in non-public event content. @sneridagh diff --git a/src/components/theme/EventDetails/EventDetails.jsx b/src/components/theme/EventDetails/EventDetails.jsx index e897f4ba49..21e6757c5f 100644 --- a/src/components/theme/EventDetails/EventDetails.jsx +++ b/src/components/theme/EventDetails/EventDetails.jsx @@ -6,7 +6,7 @@ import { Recurrence, } from '@plone/volto/components/theme/View/EventDatesInfo'; import { Icon } from '@plone/volto/components'; -import { expandToBackendURL } from '@plone/volto/helpers'; +import { flattenToAppURL } from '@plone/volto/helpers'; import calendarSVG from '@plone/volto/icons/calendar.svg'; @@ -147,7 +147,7 @@ const EventDetails = ({ content, display_as = 'aside' }) => { className="ics-download" target="_blank" rel="noreferrer" - href={`${expandToBackendURL(content['@id'])}/ics_view`} + href={`${flattenToAppURL(content['@id'])}/ics_view`} > {intl.formatMessage(messages.downloadEvent)} </a> diff --git a/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap b/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap index 1d605e546b..a7fad6aa2f 100644 --- a/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap +++ b/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap @@ -127,7 +127,7 @@ exports[`renders event details component with all props 1`] = ` /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > @@ -169,7 +169,7 @@ exports[`renders event details component with only required props 1`] = ` /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > @@ -211,7 +211,7 @@ exports[`renders event details component without links to api in the text 1`] = /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > diff --git a/src/components/theme/View/__snapshots__/EventView.test.jsx.snap b/src/components/theme/View/__snapshots__/EventView.test.jsx.snap index acf53acafc..269d255c4b 100644 --- a/src/components/theme/View/__snapshots__/EventView.test.jsx.snap +++ b/src/components/theme/View/__snapshots__/EventView.test.jsx.snap @@ -251,7 +251,7 @@ exports[`renders an event view component with all props 1`] = ` /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > @@ -357,7 +357,7 @@ exports[`renders an event view component with only required props 1`] = ` /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > @@ -458,7 +458,7 @@ exports[`renders an event view component without links to api in the text 1`] = /> <a className="ics-download" - href="http://localhost:8080/Plone/++api++/my-page/ics_view" + href="/my-page/ics_view" rel="noreferrer" target="_blank" > diff --git a/src/express-middleware/files.js b/src/express-middleware/files.js index 71de6046cf..38c9ca827b 100644 --- a/src/express-middleware/files.js +++ b/src/express-middleware/files.js @@ -29,7 +29,10 @@ function filesMiddlewareFn(req, res, next) { export default function filesMiddleware() { const middleware = express.Router(); - middleware.all(['**/@@download/*', '**/@@display-file/*'], filesMiddlewareFn); + middleware.all( + ['**/@@download/*', '**/@@display-file/*', '**/ics_view'], + filesMiddlewareFn, + ); middleware.id = 'filesResourcesProcessor'; return middleware; }