Skip to content

Commit

Permalink
Merge pull request #116 from mcampa/STENCIL-3394-bug
Browse files Browse the repository at this point in the history
STENCIL-3394 should not append configId if the file is not in assets/…
  • Loading branch information
mcampa authored Apr 20, 2017
2 parents 7c235b2 + e42ebb9 commit 2af3ebf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion helpers/stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ function helper(paper) {
paper.handlebars.registerHelper('stylesheet', function (assetPath) {
const options = arguments[arguments.length - 1];
const configId = paper.settings['theme_config_id'];
const path = configId ? assetPath.replace(/\.css$/, `-${configId}.css`) : assetPath;
// append the configId only if the asset path starts with assets/css/
const path = configId && assetPath.match(/^\/?assets\/css\//)
? assetPath.replace(/\.css$/, `-${configId}.css`)
: assetPath;

const url = paper.cdnify(path);

let attrs = { rel: 'stylesheet' };
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bigcommerce/stencil-paper",
"version": "2.0.1",
"version": "2.0.2",
"description": "A stencil plugin to register partials and helpers from handlebars and returns the compiled version for the stencil platform.",
"main": "index.js",
"author": "Bigcommerce",
Expand Down
7 changes: 7 additions & 0 deletions test/helpers/stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ describe('stylesheet helper', () => {

done();
});

it('should not append configId if the file is not in assets/css/ directory', done => {
expect(c('{{{stylesheet "assets/lib/style.css" }}}', { theme_config_id: 'foo' }))
.to.be.equal('<link data-stencil-stylesheet href="/assets/lib/style.css" rel="stylesheet">');

done();
});
});

0 comments on commit 2af3ebf

Please sign in to comment.