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

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 4.1.0 to 4.1.1

6

History.md
4.1.1 / 2017-09-25
==================
* Fix brotli support, closes #83
* Fix tests
4.1.0 / 2017-04-26

@@ -3,0 +9,0 @@ ==================

13

index.js

@@ -73,11 +73,14 @@ /**

let encodingExt = ''
// serve brotli file when possible otherwise gzipped file when possible
if (ctx.acceptsEncodings('br', 'deflate', 'identity') === 'br' && brotli && (await fs.exists(path + '.br'))) {
if (ctx.acceptsEncodings('br', 'identity') === 'br' && brotli && (await fs.exists(path + '.br'))) {
path = path + '.br'
ctx.set('Content-Encoding', 'br')
ctx.res.removeHeader('Content-Length')
} else if (ctx.acceptsEncodings('gzip', 'deflate', 'identity') === 'gzip' && gzip && (await fs.exists(path + '.gz'))) {
encodingExt = '.br'
} else if (ctx.acceptsEncodings('gzip', 'identity') === 'gzip' && gzip && (await fs.exists(path + '.gz'))) {
path = path + '.gz'
ctx.set('Content-Encoding', 'gzip')
ctx.res.removeHeader('Content-Length')
encodingExt = '.gz'
}

@@ -137,3 +140,3 @@

}
ctx.type = type(path)
ctx.type = type(path, encodingExt)
ctx.body = fs.createReadStream(path)

@@ -160,4 +163,4 @@

function type (file) {
return extname(basename(file, '.gz'))
function type (file, ext) {
return ext !== '' ? extname(basename(file, ext)) : extname(file)
}

@@ -164,0 +167,0 @@

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

"repository": "koajs/send",
"version": "4.1.0",
"version": "4.1.1",
"keywords": [

@@ -8,0 +8,0 @@ "koa",

@@ -22,8 +22,9 @@

- `maxage` Browser cache max-age in milliseconds. (defaults to `0`)
- `immutable` Tell the browser the resource is immutable and can be cached indefinitely (defaults to `false`)
- `immutable` Tell the browser the resource is immutable and can be cached indefinitely. (defaults to `false`)
- `hidden` Allow transfer of hidden files. (defaults to `false`)
- [`root`](#root-path) Root directory to restrict file access
- `gzip` Try to serve the gzipped version of a file automatically when `gzip` is supported by a client and if the requested file with `.gz` extension exists. defaults to true.
- `brotli` Try to serve the brotli version of a file automatically when `brotli` is supported by a client and if the requested file with `.br` extension exists. defaults to true.
- `format` If not `false` (defaults to `true`), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both `/directory` and `/directory/`
- [`root`](#root-path) Root directory to restrict file access.
- `index` Name of the index file to serve automatically when visiting the root location. (defaults to none)
- `gzip` Try to serve the gzipped version of a file automatically when `gzip` is supported by a client and if the requested file with `.gz` extension exists. (defaults to `true`).
- `brotli` Try to serve the brotli version of a file automatically when `brotli` is supported by a client and if the requested file with `.br` extension exists. (defaults to `true`).
- `format` If not `false` (defaults to `true`), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both `/directory` and `/directory/`.
- [`setHeaders`](#setheaders) Function to set custom headers on response.

@@ -30,0 +31,0 @@ - `extensions` Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to `false`)

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