Skip to content

Commit 8793927

Browse files
author
Mick Ryan
committed
Merge pull request #70 from mickr/modify-cdnify-for-webdav
BIG-24959 - Add webdav support to cdn helper
2 parents 8bfda2b + b817dd5 commit 8793927

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = function (assembler) {
5353
};
5454

5555
/**
56-
* Load Partials/Templates
56+
* Load Partials/Templates
5757
* @param {Object} templates
5858
* @param {Function} callback
5959
*/
@@ -95,7 +95,7 @@ module.exports = function (assembler) {
9595
* @return {Object}
9696
*/
9797
self.loadTemplatesSync = function(templates) {
98-
_.each(templates, function (content, fileName) {
98+
_.each(templates, function (content, fileName) {
9999
self.handlebars.templates[fileName] = self.handlebars.compile(content, self.options);
100100
});
101101

@@ -138,6 +138,16 @@ module.exports = function (assembler) {
138138
return path;
139139
}
140140

141+
if (path.substr(0, 7) === 'webdav:') {
142+
path = path.slice(7, path.length);
143+
144+
if (path[0] === '/') {
145+
path = path.slice(1, path.length);
146+
}
147+
148+
return [cdnUrl, 'content', path].join('/');
149+
}
150+
141151
if (path[0] !== '/') {
142152
path = '/' + path;
143153
}

test/helpers/cdn.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('cdn helper', function() {
1717
theme_version_id: '123',
1818
theme_config_id: '3245',
1919
}
20-
}
20+
};
2121

2222
it('should render the css cdn url', function(done) {
2323
expect(c('{{cdn "assets/css/style.css"}}', context))
@@ -70,4 +70,15 @@ describe('cdn helper', function() {
7070

7171
done();
7272
});
73+
74+
it('should return a webDav asset if webdav protocol specified', function(done) {
75+
76+
expect(c('{{cdn "webdav:img/image.jpg"}}', context))
77+
.to.be.equal('https://cdn.bcapp/3dsf74g/content/img/image.jpg');
78+
79+
expect(c('{{cdn "webdav:/img/image.jpg"}}', context))
80+
.to.be.equal('https://cdn.bcapp/3dsf74g/content/img/image.jpg');
81+
82+
done();
83+
});
7384
});

0 commit comments

Comments
 (0)