Socket
Socket
Sign inDemoInstall

koa-send

Package Overview
Dependencies
Maintainers
9
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-send - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

8

History.md
3.1.0 / 2015-10-24
==================
* return a promise instead of a generator
* fix: split path by path.sep instead of slash
* fix: strip root correctly on windows
* tests: resolve paths for windows
3.0.1 / 2015-10-23

@@ -3,0 +11,0 @@ ==================

38

index.js

@@ -13,3 +13,6 @@ /**

var resolve = path.resolve;
var parse = path.parse;
var sep = path.sep;
var fs = require('mz/fs');
var co = require('co');

@@ -34,20 +37,21 @@ /**

function send(ctx, path, opts) {
assert(ctx, 'koa context required');
assert(path, 'pathname required');
opts = opts || {};
return co(function *(){
// options
debug('send "%s" %j', path, opts);
var root = opts.root ? normalize(resolve(opts.root)) : '';
var trailingSlash = '/' == path[path.length - 1];
path = path[0] == '/' ? path.slice(1) : path;
var index = opts.index;
var maxage = opts.maxage || opts.maxAge || 0;
var hidden = opts.hidden || false;
var format = opts.format === false ? false : true;
var gzip = opts.gzip === false ? false : true;
assert(ctx, 'koa context required');
assert(path, 'pathname required');
opts = opts || {};
return function *(){
var encoding = this.acceptsEncodings('gzip', 'deflate', 'identity');
// options
debug('send "%s" %j', path, opts);
var root = opts.root ? normalize(resolve(opts.root)) : '';
var trailingSlash = '/' == path[path.length - 1];
path = path.substr(parse(path).root.length);
var index = opts.index;
var maxage = opts.maxage || opts.maxAge || 0;
var hidden = opts.hidden || false;
var format = opts.format === false ? false : true;
var gzip = opts.gzip === false ? false : true;
var encoding = ctx.acceptsEncodings('gzip', 'deflate', 'identity');
// normalize path

@@ -103,3 +107,3 @@ path = decode(path);

return path;
}
});
}

@@ -112,3 +116,3 @@

function isHidden(root, path) {
path = path.substr(root.length).split('/');
path = path.substr(root.length).split(sep);
for(var i = 0; i < path.length; i++) {

@@ -115,0 +119,0 @@ if(path[i][0] === '.') return true;

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

"repository": "koajs/send",
"version": "3.0.1",
"version": "3.1.0",
"keywords": [

@@ -25,2 +25,3 @@ "koa",

"dependencies": {
"co": "^4.6.0",
"debug": "*",

@@ -27,0 +28,0 @@ "mz": "^2.1.0",

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