feat: add deprecation warnings for redirect arguments undefined (#6405)

This commit is contained in:
Sebastian Beltran 2025-07-14 22:18:10 -05:00 committed by GitHub
parent 7a9311216a
commit c5b8d55a6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,7 @@
var contentDisposition = require('content-disposition');
var createError = require('http-errors')
var deprecate = require('depd')('express');
var encodeUrl = require('encodeurl');
var escapeHtml = require('escape-html');
var http = require('node:http');
@ -826,6 +827,18 @@ res.redirect = function redirect(url) {
address = arguments[1]
}
if (!address) {
deprecate('Provide a url argument');
}
if (typeof address !== 'string') {
deprecate('Url must be a string');
}
if (typeof status !== 'number') {
deprecate('Status must be a number');
}
// Set location header
address = this.location(address).get('Location');

View File

@ -39,6 +39,7 @@
"cookie": "^0.7.1",
"cookie-signature": "^1.2.1",
"debug": "^4.4.0",
"depd": "^2.0.0",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",