Skip to content
Myr

Request#download() now uses basename as filename

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

authored by visionmedia · committed by visionmedia · parent 223d764 · Browse files · 3 files+20 added−1 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+20 added−1 removed

  • tests:+6 added−0 removed
  • other:+14 added−1 removed

3 files+20 added−1 removed

modified:lib/express/helpers.js+12 added
modified:lib/express/request.js+2 added-1 removed
216 unmodified lines
217 },218 219 /**220 * Transfer static file at the given _path_ as an attachment.221 * The basename of _path_ is used as the attachment filename.222 *223 * @param {string} path224 * @return {Request}225 * @api public226 */227 228 download: function(path) {228 return this.attachment(path).sendfile(path)229 return this.attachment(basename(path)).sendfile(path)230 },231 232 /**233 * Set Content-Disposition header to 'attachment',
27 unmodified lines
modified:spec/spec.helpers.js+6 added
64 unmodified lines
65 it 'should return the directory path'66 dirname('/path/to/images/foo.bar.png').should.eql '/path/to/images'67 end68 end69 70 describe 'basename()'71 it 'should return a files basename'72 basename('foo/bar/baz.image.png').should.eql 'baz.image.png'73 end74 end75end