Skip to content

Commit

Permalink
Creating this.valid() middleware for external testing of responses
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Feb 6, 2017
1 parent 09b0996 commit 1e0e95e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/etag.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ETag {
}
});

if (!lheaders["cache-control"] || !regex.nonCachable.test(lheaders["cache-control"])) {
if (obj.valid(lheaders)) {
obj.register(parsed.href, {
etag: lheaders.etag,
headers: lheaders,
Expand Down Expand Up @@ -106,6 +106,10 @@ class ETag {
unregister (uri) {
this.cache.remove(this.hash(uri));
}

valid (headers) {
return !headers["cache-control"] || !regex.nonCachable.test(headers["cache-control"]);
}
}

module.exports = ETag;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiny-etag",
"version": "1.2.8",
"version": "1.3.0",
"description": "ETag middleware",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1e0e95e

Please sign in to comment.