diff --git a/HISTORY.md b/HISTORY.md index 92598fd..9eabd28 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +unreleased +========== + + * Fix regression when `root` is incorrectly set to a file + * deps: send@0.16.1 + 1.13.0 / 2017-09-27 =================== diff --git a/package.json b/package.json index 010dba2..833b974 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "encodeurl": "~1.0.1", "escape-html": "~1.0.3", "parseurl": "~1.3.2", - "send": "0.16.0" + "send": "0.16.1" }, "devDependencies": { "eslint": "3.19.0", diff --git a/test/test.js b/test/test.js index 8fc2114..20bb036 100644 --- a/test/test.js +++ b/test/test.js @@ -722,6 +722,34 @@ describe('serveStatic()', function () { }) }) + // + // NOTE: This is not a real part of the API, but + // over time this has become something users + // are doing, so this will prevent unseen + // regressions around this use-case. + // + describe('when mounted "root" as a file', function () { + var server + before(function () { + server = createServer(fixtures + '/todo.txt', null, function (req) { + req.originalUrl = req.url + req.url = '/' + req.url.split('/').slice(2).join('/') + }) + }) + + it('should load the file when on trailing slash', function (done) { + request(server) + .get('/todo') + .expect(200, '- groceries', done) + }) + + it('should 404 when trailing slash', function (done) { + request(server) + .get('/todo/') + .expect(404, done) + }) + }) + describe('when responding non-2xx or 304', function () { var server before(function () {