Skip to content

Commit 36f46e4

Browse files
committed
Merge branch 'dev'
2 parents ebaba11 + bca5920 commit 36f46e4

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

packages/core/src/lib/compose.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ module.exports = function(pattern, patternlab) {
164164
logger.info(err);
165165
}
166166
allFooterData = _.merge(allFooterData, pattern.jsonFileData);
167+
allFooterData.cacheBuster = patternlab.cacheBuster;
167168
allFooterData.patternLabFoot = footerPartial;
168169

169170
return render(patternlab.userFoot, allFooterData).then(footerHTML => {

packages/live-server/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ function staticServer(root) {
4848
var hasNoOrigin = !req.headers.origin;
4949
var injectCandidates = [
5050
new RegExp('</body>', 'i'),
51-
new RegExp('</svg>'),
51+
new RegExp('</svg>', 'g'),
5252
new RegExp('</head>', 'i'),
5353
];
5454
var injectTag = null;
55+
var injectCount = 0;
5556

5657
function directory() {
5758
var pathname = url.parse(req.originalUrl).pathname;
@@ -62,15 +63,16 @@ function staticServer(root) {
6263

6364
function file(filepath /*, stat*/) {
6465
var x = path.extname(filepath).toLocaleLowerCase(),
65-
match,
66+
matches,
6667
possibleExtensions = ['', '.html', '.htm', '.xhtml', '.php', '.svg'];
6768
if (hasNoOrigin && possibleExtensions.indexOf(x) > -1) {
6869
// TODO: Sync file read here is not nice, but we need to determine if the html should be injected or not
6970
var contents = fs.readFileSync(filepath, 'utf8');
7071
for (var i = 0; i < injectCandidates.length; ++i) {
71-
match = injectCandidates[i].exec(contents);
72-
if (match) {
73-
injectTag = match[0];
72+
matches = contents.match(injectCandidates[i]);
73+
injectCount = matches && matches.length || 0;
74+
if (injectCount) {
75+
injectTag = matches[0];
7476
break;
7577
}
7678
}
@@ -94,7 +96,7 @@ function staticServer(root) {
9496
function inject(stream) {
9597
if (injectTag) {
9698
// We need to modify the length given to browser
97-
var len = INJECTED_CODE.length + res.getHeader('Content-Length');
99+
var len = INJECTED_CODE.length * injectCount + res.getHeader('Content-Length');
98100
res.setHeader('Content-Length', len);
99101
var originalPipe = stream.pipe;
100102
stream.pipe = function(resp) {

packages/live-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"opn": "5.3.0",
2525
"proxy-middleware": "0.15.0",
2626
"send": "0.16.2",
27-
"serve-index": "1.7.2"
27+
"serve-index": "1.9.1"
2828
},
2929
"devDependencies": {
3030
"eslint": "4.18.2",

0 commit comments

Comments
 (0)