Skip to content

Commit

Permalink
Remove deprecated hidden option
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 3, 2022
1 parent 889d310 commit 85dfcd7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 69 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -2,6 +2,7 @@
===

* Drop support for Node.js 0.8
* Remove `hidden` option -- use `dotfiles` option
* Remove `from` alias to `root` -- use `root` directly
* Remove `send.etag()` -- use `etag` in `options`
* Remove `send.index()` -- use `index` in `options`
Expand Down
40 changes: 2 additions & 38 deletions index.js
Expand Up @@ -14,7 +14,6 @@

var createError = require('http-errors')
var debug = require('debug')('send')
var deprecate = require('depd')('send')
var destroy = require('destroy')
var encodeUrl = require('encodeurl')
var escapeHtml = require('escape-html')
Expand Down Expand Up @@ -121,17 +120,6 @@ function SendStream (req, path, options) {
throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"')
}

this._hidden = Boolean(opts.hidden)

if (opts.hidden !== undefined) {
deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead')
}

// legacy support
if (opts.dotfiles === undefined) {
this._dotfiles = undefined
}

this._extensions = opts.extensions !== undefined
? normalizeList(opts.extensions, 'extensions option')
: []
Expand Down Expand Up @@ -167,21 +155,6 @@ function SendStream (req, path, options) {

util.inherits(SendStream, Stream)

/**
* Enable or disable "hidden" (dot) files.
*
* @param {Boolean} path
* @return {SendStream}
* @api public
*/

SendStream.prototype.hidden = deprecate.function(function hidden (val) {
this._hidden = Boolean(val)
this._dotfiles = undefined
debug('hidden %s', this._hidden)
return this
}, 'send.hidden: use dotfiles option')

/**
* Emit error with `status`.
*
Expand Down Expand Up @@ -489,17 +462,8 @@ SendStream.prototype.pipe = function pipe (res) {

// dotfile handling
if (containsDotFile(parts)) {
var access = this._dotfiles

// legacy support
if (access === undefined) {
access = parts[parts.length - 1][0] === '.'
? (this._hidden ? 'allow' : 'ignore')
: 'allow'
}

debug('%s dotfile "%s"', access, path)
switch (access) {
debug('%s dotfile "%s"', this._dotfiles, path)
switch (this._dotfiles) {
case 'allow':
break
case 'deny':
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -17,7 +17,6 @@
],
"dependencies": {
"debug": "2.6.9",
"depd": "~1.1.2",
"destroy": "~1.0.4",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
Expand Down
32 changes: 2 additions & 30 deletions test/send.js
Expand Up @@ -778,20 +778,6 @@ describe('send(file).pipe(res)', function () {
.expect(416, done)
})
})

describe('.hidden()', function () {
it('should default support sending hidden files', function (done) {
var app = http.createServer(function (req, res) {
send(req, req.url, { root: fixtures })
.hidden(true)
.pipe(res)
})

request(app)
.get('/.hidden.txt')
.expect(200, 'secret', done)
})
})
})

describe('send(file, options)', function () {
Expand Down Expand Up @@ -910,10 +896,10 @@ describe('send(file, options)', function () {
.expect(404, done)
})

it('should allow file within dotfile directory for back-compat', function (done) {
it('should ignore file within dotfile directory', function (done) {
request(createServer({ root: fixtures }))
.get('/.mine/name.txt')
.expect(200, /tobi/, done)
.expect(404, done)
})

it('should reject bad value', function (done) {
Expand Down Expand Up @@ -1063,20 +1049,6 @@ describe('send(file, options)', function () {
})
})

describe('hidden', function () {
it('should default to false', function (done) {
request(app)
.get('/.hidden.txt')
.expect(404, 'Not Found', done)
})

it('should default support sending hidden files', function (done) {
request(createServer({ hidden: true, root: fixtures }))
.get('/.hidden.txt')
.expect(200, 'secret', done)
})
})

describe('immutable', function () {
it('should default to false', function (done) {
request(createServer({ root: fixtures }))
Expand Down

0 comments on commit 85dfcd7

Please sign in to comment.