Comparing version 1.0.9 to 1.0.10
@@ -12,2 +12,3 @@ /* jshint node:true */ | ||
function ESI(config) { | ||
var self = this; | ||
config = config || {}; | ||
@@ -21,2 +22,12 @@ | ||
this.logger = new Logger(config); | ||
if(typeof this.cache.on === 'function') { | ||
this.cache.on('error', function(err) { | ||
self.logger.write('ESI: custom cache emitted an error:'); | ||
self.logger.write('ESI: ' + err); | ||
self.logger.write('ESI: falling back to default cache'); | ||
self.cache = new Cache(config); | ||
}); | ||
} | ||
} | ||
@@ -96,3 +107,3 @@ | ||
if(nextTagFullClose > -1 && | ||
(Math.max(0, nextTagFullClose - fullClose.length) < Math.max(0, nextTagSelfClose - selfClose.length)) || | ||
(Math.max(0, nextTagFullClose - fullClose.length) < Math.max(0, nextTagSelfClose - selfClose.length)) || | ||
nextTagSelfClose === -1) { | ||
@@ -99,0 +110,0 @@ tags.push(reducedHtml.substr(0, nextTagFullClose + fullClose.length)); |
{ | ||
"name": "nodesi", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "ESI: the good parts in node.js", | ||
@@ -5,0 +5,0 @@ "main": "esi.js", |
@@ -9,2 +9,3 @@ /* jshint node:true */ | ||
fs = require('fs'), | ||
events = require('events'), | ||
Promise = require('bluebird'), | ||
@@ -493,2 +494,27 @@ | ||
it('should gracefully fall to default cache upon custom cache error', function() { | ||
// given | ||
var CustomCache = function() { | ||
events.EventEmitter.call(this); | ||
}; | ||
CustomCache.prototype = Object.create(events.EventEmitter.prototype, { | ||
constructor: { | ||
value: CustomCache | ||
} | ||
}); | ||
var customCache = new CustomCache(); | ||
// when | ||
var esi = new ESI({ | ||
cache: customCache | ||
}); | ||
customCache.emit('error', new Error('Connection error')); | ||
// then | ||
assert.ok(esi.cache instanceof Cache); | ||
assert.ok(!(esi.cache instanceof CustomCache)); | ||
}); | ||
it('should fetch components recursively', function (done) { | ||
@@ -495,0 +521,0 @@ // given |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
964472
991