Skip to content

Commit 85dfcd7

Browse files
committed
Remove deprecated hidden option
1 parent 889d310 commit 85dfcd7

File tree

4 files changed

+5
-69
lines changed

4 files changed

+5
-69
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
===
33

44
* Drop support for Node.js 0.8
5+
* Remove `hidden` option -- use `dotfiles` option
56
* Remove `from` alias to `root` -- use `root` directly
67
* Remove `send.etag()` -- use `etag` in `options`
78
* Remove `send.index()` -- use `index` in `options`

index.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

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

124-
this._hidden = Boolean(opts.hidden)
125-
126-
if (opts.hidden !== undefined) {
127-
deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead')
128-
}
129-
130-
// legacy support
131-
if (opts.dotfiles === undefined) {
132-
this._dotfiles = undefined
133-
}
134-
135123
this._extensions = opts.extensions !== undefined
136124
? normalizeList(opts.extensions, 'extensions option')
137125
: []
@@ -167,21 +155,6 @@ function SendStream (req, path, options) {
167155

168156
util.inherits(SendStream, Stream)
169157

170-
/**
171-
* Enable or disable "hidden" (dot) files.
172-
*
173-
* @param {Boolean} path
174-
* @return {SendStream}
175-
* @api public
176-
*/
177-
178-
SendStream.prototype.hidden = deprecate.function(function hidden (val) {
179-
this._hidden = Boolean(val)
180-
this._dotfiles = undefined
181-
debug('hidden %s', this._hidden)
182-
return this
183-
}, 'send.hidden: use dotfiles option')
184-
185158
/**
186159
* Emit error with `status`.
187160
*
@@ -489,17 +462,8 @@ SendStream.prototype.pipe = function pipe (res) {
489462

490463
// dotfile handling
491464
if (containsDotFile(parts)) {
492-
var access = this._dotfiles
493-
494-
// legacy support
495-
if (access === undefined) {
496-
access = parts[parts.length - 1][0] === '.'
497-
? (this._hidden ? 'allow' : 'ignore')
498-
: 'allow'
499-
}
500-
501-
debug('%s dotfile "%s"', access, path)
502-
switch (access) {
465+
debug('%s dotfile "%s"', this._dotfiles, path)
466+
switch (this._dotfiles) {
503467
case 'allow':
504468
break
505469
case 'deny':

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"dependencies": {
1919
"debug": "2.6.9",
20-
"depd": "~1.1.2",
2120
"destroy": "~1.0.4",
2221
"encodeurl": "~1.0.2",
2322
"escape-html": "~1.0.3",

test/send.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -778,20 +778,6 @@ describe('send(file).pipe(res)', function () {
778778
.expect(416, done)
779779
})
780780
})
781-
782-
describe('.hidden()', function () {
783-
it('should default support sending hidden files', function (done) {
784-
var app = http.createServer(function (req, res) {
785-
send(req, req.url, { root: fixtures })
786-
.hidden(true)
787-
.pipe(res)
788-
})
789-
790-
request(app)
791-
.get('/.hidden.txt')
792-
.expect(200, 'secret', done)
793-
})
794-
})
795781
})
796782

797783
describe('send(file, options)', function () {
@@ -910,10 +896,10 @@ describe('send(file, options)', function () {
910896
.expect(404, done)
911897
})
912898

913-
it('should allow file within dotfile directory for back-compat', function (done) {
899+
it('should ignore file within dotfile directory', function (done) {
914900
request(createServer({ root: fixtures }))
915901
.get('/.mine/name.txt')
916-
.expect(200, /tobi/, done)
902+
.expect(404, done)
917903
})
918904

919905
it('should reject bad value', function (done) {
@@ -1063,20 +1049,6 @@ describe('send(file, options)', function () {
10631049
})
10641050
})
10651051

1066-
describe('hidden', function () {
1067-
it('should default to false', function (done) {
1068-
request(app)
1069-
.get('/.hidden.txt')
1070-
.expect(404, 'Not Found', done)
1071-
})
1072-
1073-
it('should default support sending hidden files', function (done) {
1074-
request(createServer({ hidden: true, root: fixtures }))
1075-
.get('/.hidden.txt')
1076-
.expect(200, 'secret', done)
1077-
})
1078-
})
1079-
10801052
describe('immutable', function () {
10811053
it('should default to false', function (done) {
10821054
request(createServer({ root: fixtures }))

0 commit comments

Comments
 (0)