Deprecate "back" magic string in redirects (#5935)

This commit is contained in:
Blake Embrey
2024-09-11 12:24:22 -07:00
committed by GitHub
parent b1b73fe55e
commit 9dc729339f
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -1,3 +1,8 @@
unreleased
==========
* Deprecate `res.location("back")` and `res.redirect("back")` magic string
4.20.0 / 2024-09-10
==========
* deps: serve-static@0.16.0
+1
View File
@@ -916,6 +916,7 @@ res.location = function location(url) {
// "back" is an alias for the referrer
if (url === 'back') {
deprecate('res.location("back"): use res.location(req.get("Referrer") || "/") and refer to https://dub.sh/security-redirect for best practices');
loc = this.req.get('Referrer') || '/';
} else {
loc = String(url);