electricity
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -331,2 +331,8 @@ var crypto = require('crypto'); | ||
if (reqInfo.hash !== file.hash) { | ||
res.set({ | ||
'Cache-Control': 'no-cache', | ||
'Expires': '0', | ||
'Pragma': 'no-cache' | ||
}); | ||
return res.redirect(hashifyPath(reqInfo.path, file.hash)); | ||
@@ -351,5 +357,7 @@ } | ||
if (req.get('If-None-Match') === file.hash) { | ||
res.send(304); | ||
res.status(304); | ||
res.end(); | ||
} else if (new Date(req.get('If-Modified-Since')) >= file.modified) { | ||
res.send(304); | ||
res.status(304); | ||
res.end(); | ||
} else { | ||
@@ -356,0 +364,0 @@ res.set({ |
@@ -35,3 +35,3 @@ { | ||
}, | ||
"version": "1.2.2" | ||
"version": "1.2.3" | ||
} |
@@ -129,2 +129,3 @@ var assert = require('assert'); | ||
}); | ||
it.skip('calls res.send with asset contents if the asset does exist', function(done) { | ||
@@ -151,2 +152,3 @@ req.path = '/robots.txt'; | ||
}); | ||
it('calls res.send with asset contents if the asset does exist and has its hash appended', function(done) { | ||
@@ -173,2 +175,3 @@ req.path = '/robots-ca121b5d03245bf82db00d14cee04e22.txt'; | ||
}); | ||
it('calls res.send with custom headers if specified', function(done) { | ||
@@ -208,2 +211,3 @@ var midwareWithHeaders = electricity.static('test/public', { | ||
}); | ||
it('should only remove the hash from the path', function(done) { | ||
@@ -230,2 +234,3 @@ req.path = '/robots-abc1de.home-ca121b5d03245bf82db00d14cee04e22.txt'; | ||
}); | ||
it('correctly serves files from subdirectories', function(done) { | ||
@@ -252,3 +257,4 @@ req.path = '/styles/normalize-dc691d63a0d03f7c0dba9f0eda398b5b.css'; | ||
}); | ||
it('sends a 302 redirect if the hash does not match the current file', function(done) { | ||
it.only('sends a 302 redirect if the hash does not match the current file', function(done) { | ||
var redirected = false; | ||
@@ -255,0 +261,0 @@ req.path = '/robots-ca121b5d03245bf82db00d1455555555.txt'; |
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
104787
1923