Skip to content

Commit 06cc938

Browse files
committed
fix: MERC-9364 Use CDN Original images for webdav - cache control
1 parent 2cacbed commit 06cc938

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

helpers/lib/cdnify.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ module.exports = globals => {
5656
}
5757

5858
if (protocol === 'webdav:') {
59-
return [cdnUrl, 'content', path].join('/');
59+
const imgRegex = /(jpg|jpeg|gif|png)$/i;
60+
const isImage = imgRegex.test(path);
61+
const prefix = isImage ? 'images/stencil/original/content' : 'content'
62+
return [cdnUrl, prefix, path].join('/');
6063
}
6164

6265
if (cdnSettings) {

spec/helpers/cdn.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,36 @@ describe('cdn helper', function () {
194194
], done);
195195
});
196196

197-
it('should return a webDav asset if webdav protocol specified', function (done) {
197+
it('should return an original cdn img asset if webdav protocol specified but file type indicates it is an image', function (done) {
198198
runTestCases([
199199
{
200200
input: '{{cdn "webdav:img/image.jpg"}}',
201-
output: 'https://cdn.bcapp/3dsf74g/content/img/image.jpg',
201+
output: 'https://cdn.bcapp/3dsf74g/images/stencil/original/content/img/image.jpg',
202202
},
203203
{
204204
input: '{{cdn "webdav:/img/image.jpg"}}',
205-
output: 'https://cdn.bcapp/3dsf74g/content/img/image.jpg',
205+
output: 'https://cdn.bcapp/3dsf74g/images/stencil/original/content/img/image.jpg',
206206
},
207207
{
208208
input: '{{cdn "webdav://img/image.jpg"}}',
209-
output: 'https://cdn.bcapp/3dsf74g/content/img/image.jpg',
209+
output: 'https://cdn.bcapp/3dsf74g/images/stencil/original/content/img/image.jpg',
210+
},
211+
], done);
212+
});
213+
214+
it('should return a webDav asset if webdav protocol specified but is not a supported image type', function (done) {
215+
runTestCases([
216+
{
217+
input: '{{cdn "webdav:img/image.pdf"}}',
218+
output: 'https://cdn.bcapp/3dsf74g/content/img/image.pdf',
219+
},
220+
{
221+
input: '{{cdn "webdav:/img/image.pdf"}}',
222+
output: 'https://cdn.bcapp/3dsf74g/content/img/image.pdf',
223+
},
224+
{
225+
input: '{{cdn "webdav://img/image.pdf"}}',
226+
output: 'https://cdn.bcapp/3dsf74g/content/img/image.pdf',
210227
},
211228
], done);
212229
});

0 commit comments

Comments
 (0)