From c5b8d55a6a941fb5f8c783f7734a32f40142c4d9 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Mon, 14 Jul 2025 22:18:10 -0500 Subject: [PATCH] feat: add deprecation warnings for redirect arguments undefined (#6405) --- lib/response.js | 13 +++++++++++++ package.json | 1 + 2 files changed, 14 insertions(+) diff --git a/lib/response.js b/lib/response.js index 09fa0611..7a2f0ecc 100644 --- a/lib/response.js +++ b/lib/response.js @@ -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'); diff --git a/package.json b/package.json index bdcd25e6..104528ab 100644 --- a/package.json +++ b/package.json @@ -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",