Skip to content

Commit c5b8d55

Browse files
authored
feat: add deprecation warnings for redirect arguments undefined (#6405)
1 parent 7a93112 commit c5b8d55

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/response.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
var contentDisposition = require('content-disposition');
1616
var createError = require('http-errors')
17+
var deprecate = require('depd')('express');
1718
var encodeUrl = require('encodeurl');
1819
var escapeHtml = require('escape-html');
1920
var http = require('node:http');
@@ -826,6 +827,18 @@ res.redirect = function redirect(url) {
826827
address = arguments[1]
827828
}
828829

830+
if (!address) {
831+
deprecate('Provide a url argument');
832+
}
833+
834+
if (typeof address !== 'string') {
835+
deprecate('Url must be a string');
836+
}
837+
838+
if (typeof status !== 'number') {
839+
deprecate('Status must be a number');
840+
}
841+
829842
// Set location header
830843
address = this.location(address).get('Location');
831844

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"cookie": "^0.7.1",
4040
"cookie-signature": "^1.2.1",
4141
"debug": "^4.4.0",
42+
"depd": "^2.0.0",
4243
"encodeurl": "^2.0.0",
4344
"escape-html": "^1.0.3",
4445
"etag": "^1.8.1",

0 commit comments

Comments
 (0)