Skip to content
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

STENCIL-3394 should not append configId if the file is not in assets/… #116

Merged
merged 1 commit into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});