mirror of
https://github.com/expressjs/express.git
synced 2026-02-21 19:41:36 +00:00
feat: add deprecation warnings for redirect arguments undefined (#6405)
This commit is contained in:
committed by
GitHub
parent
7a9311216a
commit
c5b8d55a6a
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user