Skip to content

Commit e7c5bf0

Browse files
committed
fix for passing in an abolute url to css helper
1 parent 268e800 commit e7c5bf0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/html.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ helpers.css = function(list, options) {
6161

6262
return styles.map(function(item) {
6363
var ext = path.extname(item);
64-
var fp = path.posix.join(assets, item);
64+
var fp = item;
65+
66+
var isExternal = /(^\/\/)|(:\/\/)/.test(item);
67+
if(!isExternal) {
68+
fp = path.posix.join(assets, item);
69+
}
6570

6671
if (ext === '.less') {
6772
return '<link type="text/css" rel="stylesheet/less" href="' + fp + '">';

test/html.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ describe('html', function() {
3838
assert.equal(actual, '<link type="text/css" rel="stylesheet" href="abc.css">');
3939
});
4040

41+
it('should not use options.assets when passing in an absolute url', function() {
42+
var actual = hbs.compile('{{{css "https://abc.com/bar.css"}}}')({options: {assets: "foo"}});
43+
assert.equal(actual, '<link type="text/css" rel="stylesheet" href="https://abc.com/bar.css">');
44+
});
45+
4146
it('should use the `href` attribute on the hash', function() {
4247
actual = hbs.compile('{{{css href=""}}}')();
4348
assert.equal(actual, '');

0 commit comments

Comments
 (0)