Skip to content

Commit

Permalink
Deprecate "back" magic string in redirects (#5935)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Sep 11, 2024
1 parent 21df421 commit 77ada90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 77ada90

Please sign in to comment.