Files
0065edc45d Upgrade content-disposition (#7233)
* Upgrade content-disposition

* Better backward compat

* chore: upgrade content-disposition to 2.0.1 and update History.md

* test: add case for encoding latin1 file names with ASCII fallback in attachment

* test: add cases for quoting invalid file names and handling empty file names in attachment

---------

Co-authored-by: Sebastian Beltran <[email protected]>
2026-06-15 21:45:22 -05:00

48 lines
1.2 KiB
JavaScript

var app = require('../../examples/downloads')
, request = require('supertest');
describe('downloads', function(){
describe('GET /', function(){
it('should have a link to amazing.txt', function(done){
request(app)
.get('/')
.expect(/href="\/files\/amazing.txt"/, done)
})
})
describe('GET /files/notes/groceries.txt', function () {
it('should have a download header', function (done) {
request(app)
.get('/files/notes/groceries.txt')
.expect('Content-Disposition', 'attachment; filename=groceries.txt')
.expect(200, done)
})
})
describe('GET /files/amazing.txt', function(){
it('should have a download header', function(done){
request(app)
.get('/files/amazing.txt')
.expect('Content-Disposition', 'attachment; filename=amazing.txt')
.expect(200, done)
})
})
describe('GET /files/missing.txt', function(){
it('should respond with 404', function(done){
request(app)
.get('/files/missing.txt')
.expect(404, done)
})
})
describe('GET /files/../index.js', function () {
it('should respond with 403', function (done) {
request(app)
.get('/files/../index.js')
.expect(403, done)
})
})
})