Skip to content
Myr

Improve error message for non-strings to res.sendFile

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #3582

authored by void · committed by Douglas Christopher Wilson · parent 44e539e · Browse files · 3 files+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−0 removed

  • tests:+8 added−0 removed
  • other:+9 added−0 removed

3 files+17 added−0 removed

modified:lib/response.js+4 added
409 unmodified lines
410 if (!path) {411 throw new TypeError('path argument is required to res.sendFile');412 }413414 if (typeof path !== 'string') {415 throw new TypeError('path must be a string to res.sendFile')416 }417418 // support function as second arg419 if (typeof options === 'function') {420 done = options;421 opts = {};
720 unmodified lines
modified:test/res.sendFile.js+8 added
18 unmodified lines
19 .get('/')20 .expect(500, /path.*required/, done);21 });2223 it('should error for non-string path', function (done) {24 var app = createApp(42)2526 request(app)27 .get('/')28 .expect(500, /TypeError: path must be a string to res.sendFile/, done)29 })3031 it('should transfer a file', function (done) {32 var app = createApp(path.resolve(fixtures, 'name.txt'));3334 request(app)
792 unmodified lines
modified:History.md+5 added
1unreleased2==========34 * Improve error message for non-strings to `res.sendFile`564.16.4 / 2018-10-107===================89 * Fix issue where `"Request aborted"` may be logged in `res.sendfile`
3417 unmodified lines