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

koa-etag

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-etag - npm Package Compare versions

Comparing version 1.1.0 to 1.2.1

52

index.js

@@ -24,37 +24,35 @@

function etag() {
return function(next){
return function *(){
yield next;
return function *(next){
yield next;
// no body
var body = this.body;
if (!body) return;
// no body
var body = this.body;
if (!body) return;
// type
var status = this.status / 100 | 0;
var type = typeof body;
var etag;
// type
var status = this.status / 100 | 0;
var type = typeof body;
var etag;
// 2xx
if (2 != status) return;
// 2xx
if (2 != status) return;
// stream
if (body instanceof Stream) {
if (!body.path) return;
var s = yield stat(body.path);
etag = crc(s.size + '.' + s.mtime);
}
// stream
if (body instanceof Stream) {
if (!body.path) return;
var s = yield stat(body.path);
etag = crc(s.size + '.' + s.mtime);
}
// string
if ('string' == type) etag = crc(body);
// string
if ('string' == type) etag = crc(body);
// buffer
if (Buffer.isBuffer(body)) etag = crc(body);
// buffer
if (Buffer.isBuffer(body)) etag = crc(body);
// json
etag = crc(JSON.stringify(body));
// json
etag = crc(JSON.stringify(body));
// add etag
if (etag) this.set('ETag', '"' + etag + '"');
}
// add etag
if (etag) this.set('ETag', '"' + etag + '"');
}

@@ -61,0 +59,0 @@ }

@@ -5,3 +5,3 @@ {

"repository": "koajs/etag",
"version": "1.1.0",
"version": "1.2.1",
"keywords": [

@@ -21,6 +21,7 @@ "koa",

"devDependencies": {
"koa": "0.0.1",
"koa": "koajs/koa",
"should": "~1.2.2",
"mocha": "~1.12.0",
"supertest": "~0.7.1"
"supertest": "~0.7.1",
"koa-static": "1.3.0"
},

@@ -27,0 +28,0 @@ "license": "MIT",

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