Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodesi

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodesi - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

26

lib/esi.js

@@ -152,3 +152,3 @@ /* jshint node:true, quotmark:false */

return new Promise(function (resolve, reject) {
self.cache.get(src)
var cached = (options.ignoreCache) ? Promise.reject() : self.cache.get(src)
// in cache

@@ -163,14 +163,16 @@ .then(function (result) {

resolve(result.value);
})
// not in cache
.catch(function () {
self.dataProvider.get(src, options)
.then(function (result) {
});
// not in cache or cache ignored
cached.catch(function () {
self.dataProvider.get(src, options)
.then(function (result) {
if (!options.ignoreCache) {
self.setCacheResult(src, result);
resolve(result.body);
})
.catch(function (error) {
resolve(self.handleError(src, error));
});
});
}
resolve(result.body);
})
.catch(function (error) {
resolve(self.handleError(src, error));
});
});
});

@@ -177,0 +179,0 @@ };

{
"name": "nodesi",
"version": "1.0.12",
"version": "1.0.13",
"description": "ESI: the good parts in node.js",

@@ -5,0 +5,0 @@ "main": "esi.js",

@@ -556,2 +556,37 @@ /* jshint node:true, quotmark:false */

it('should ignore cache for selected requests', function (done) {
// given
server.addListener('request', function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('hello');
});
var html = '<esi:include src="/cacheme"></esi:include>';
// when
var esi = new ESI({
baseUrl: 'http://localhost:' + port
});
esi.cache.set('http://localhost:' + port + '/cacheme', {
value: 'stuff',
expiresIn: 1
});
var processed = esi.process(html, {
ignoreCache: true
});
// then
processed.then(function (response) {
assert.equal(response, 'hello');
return esi.cache.get('http://localhost:' + port + '/cacheme');
}).then(function (cached) {
assert.equal(cached.value, 'stuff');
done();
}).catch(done);
});
it('should fetch components recursively', function (done) {

@@ -558,0 +593,0 @@ // given

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc