Skip to content

Commit 2d47897

Browse files
committed
Remove deprecated maxage method
1 parent 0b7bd4b commit 2d47897

File tree

3 files changed

+5
-69
lines changed

3 files changed

+5
-69
lines changed

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.x
2+
===
3+
4+
* Remove `send.maxage()` -- use `maxAge` in `options`
5+
16
0.17.2 / 2021-12-11
27
===================
38

index.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -237,25 +237,6 @@ SendStream.prototype.from = deprecate.function(SendStream.prototype.root,
237237
SendStream.prototype.root = deprecate.function(SendStream.prototype.root,
238238
'send.root: pass root as option')
239239

240-
/**
241-
* Set max-age to `maxAge`.
242-
*
243-
* @param {Number} maxAge
244-
* @return {SendStream}
245-
* @api public
246-
*/
247-
248-
SendStream.prototype.maxage = deprecate.function(function maxage (maxAge) {
249-
this._maxage = typeof maxAge === 'string'
250-
? ms(maxAge)
251-
: Number(maxAge)
252-
this._maxage = !isNaN(this._maxage)
253-
? Math.min(Math.max(0, this._maxage), MAX_MAXAGE)
254-
: 0
255-
debug('max-age %d', this._maxage)
256-
return this
257-
}, 'send.maxage: pass maxAge as option')
258-
259240
/**
260241
* Emit error with `status`.
261242
*

test/send.js

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -853,56 +853,6 @@ describe('send(file).pipe(res)', function () {
853853
})
854854
})
855855

856-
describe('.maxage()', function () {
857-
it('should default to 0', function (done) {
858-
var app = http.createServer(function (req, res) {
859-
send(req, 'test/fixtures/name.txt')
860-
.maxage(undefined)
861-
.pipe(res)
862-
})
863-
864-
request(app)
865-
.get('/name.txt')
866-
.expect('Cache-Control', 'public, max-age=0', done)
867-
})
868-
869-
it('should floor to integer', function (done) {
870-
var app = http.createServer(function (req, res) {
871-
send(req, 'test/fixtures/name.txt')
872-
.maxage(1234)
873-
.pipe(res)
874-
})
875-
876-
request(app)
877-
.get('/name.txt')
878-
.expect('Cache-Control', 'public, max-age=1', done)
879-
})
880-
881-
it('should accept string', function (done) {
882-
var app = http.createServer(function (req, res) {
883-
send(req, 'test/fixtures/name.txt')
884-
.maxage('30d')
885-
.pipe(res)
886-
})
887-
888-
request(app)
889-
.get('/name.txt')
890-
.expect('Cache-Control', 'public, max-age=2592000', done)
891-
})
892-
893-
it('should max at 1 year', function (done) {
894-
var app = http.createServer(function (req, res) {
895-
send(req, 'test/fixtures/name.txt')
896-
.maxage(Infinity)
897-
.pipe(res)
898-
})
899-
900-
request(app)
901-
.get('/name.txt')
902-
.expect('Cache-Control', 'public, max-age=31536000', done)
903-
})
904-
})
905-
906856
describe('.root()', function () {
907857
it('should set root', function (done) {
908858
var app = http.createServer(function (req, res) {

0 commit comments

Comments
 (0)