-
Notifications
You must be signed in to change notification settings - Fork 40
fix(cdn): MERC-9364 Use CDN Original images for webdav - cache control #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,14 @@ module.exports = globals => { | |
} | ||
|
||
if (protocol === 'webdav:') { | ||
return [cdnUrl, 'content', path].join('/'); | ||
const supportedImageExtensions = ['jpg', 'jpeg', 'gif', 'png']; | ||
const unsupportedPathSyntaxes = ['../', './']; | ||
const searchParamIgnoredPath = path.split('?')[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should cover cases when pathname contains searchParams like |
||
const isImage = supportedImageExtensions.some(ext => searchParamIgnoredPath.toLowerCase().endsWith(ext)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously used method Now the logic has been updated, so firstly we exclude searchParams from path and then check if it ends with supported extension. |
||
const isTraversedPathUsed = unsupportedPathSyntaxes.some(syntax => searchParamIgnoredPath.startsWith(syntax)); | ||
// to avoid breaking changes, we keep paths for webdav content unchanged if the path is traversed | ||
const prefix = isImage && !isTraversedPathUsed ? 'images/stencil/original/content' : 'content' | ||
return [cdnUrl, prefix, path].join('/'); | ||
} | ||
|
||
if (cdnSettings) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include
.
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think no, Jay. On L61 I exclude any searchParams from path and what is left I check if it ends with supported extension. So for example User provides something like:
webdav:/collection/gifts/image.pdf?cache-buster=2025-06-04T00:50:40
.We then check first if it webdav, then go and look for any searchParams and drop them so receive path:
/collection/gifts/image.pdf
and then check if it ends with supported extensions.