Skip to content

Commit

Permalink
remove backwards compatibilty of dotfiles (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Jan 14, 2023
1 parent 9f0df93 commit 3d6de26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
17 changes: 2 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ function SendStream (req, path, options) {
throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"')
}

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

this._extensions = opts.extensions !== undefined
? normalizeList(opts.extensions, 'extensions option')
: []
Expand Down Expand Up @@ -481,16 +476,8 @@ SendStream.prototype.pipe = function pipe (res) {

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

if (access === undefined) {
access = parts[parts.length - 1][0] === '.'
? '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
10 changes: 1 addition & 9 deletions test/send.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test('send(file, options)', function (t) {
})

t.test('dotfiles', function (t) {
t.plan(6)
t.plan(5)

t.test('should default to "ignore"', function (t) {
t.plan(1)
Expand All @@ -173,14 +173,6 @@ test('send(file, options)', function (t) {
.expect(404, err => t.error(err))
})

t.test('should allow file within dotfile directory for back-compat', function (t) {
t.plan(1)

request(createServer({ root: fixtures }))
.get('/.mine/name.txt')
.expect(200, /tobi/, err => t.error(err))
})

t.test('should reject bad value', function (t) {
t.plan(1)

Expand Down

0 comments on commit 3d6de26

Please sign in to comment.