From e42ebb956ccf79921e9c28aed91dcec449a733a0 Mon Sep 17 00:00:00 2001 From: Mario Campa Date: Thu, 20 Apr 2017 12:34:28 -0700 Subject: [PATCH] STENCIL-3394 should not append configId if the file is not in assets/css/ directory --- helpers/stylesheet.js | 6 +++++- package.json | 2 +- test/helpers/stylesheet.js | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/helpers/stylesheet.js b/helpers/stylesheet.js index 0f9867ff..1d7d8ad0 100644 --- a/helpers/stylesheet.js +++ b/helpers/stylesheet.js @@ -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' }; diff --git a/package.json b/package.json index c6372748..6ecef63a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/helpers/stylesheet.js b/test/helpers/stylesheet.js index dcd8c715..bb1035b3 100644 --- a/test/helpers/stylesheet.js +++ b/test/helpers/stylesheet.js @@ -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(''); + + done(); + }); });