docs: fix ReferenceError in open-redirect example (Url -> URL) - #2465
Merged
bjohansebas merged 1 commit intoAug 1, 2026
Merged
Conversation
The open-redirect validation example calls `new Url(...)`, but the JavaScript global is `URL`. As written, the constructor throws ReferenceError on every request, the catch block swallows it, and the example responds 400 "Invalid url" for every URL - including valid ones - so the redirect never runs. Anyone copying the snippet gets a handler that silently rejects all redirects instead of validating them.
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
krzysdz
approved these changes
Jul 31, 2026
krzysdz
left a comment
Contributor
There was a problem hiding this comment.
Oops. @marco-ippolito found this in #1474 (comment), the suggestion was applied in 401c6a6 and then before merging there was a force push, which reformatted the code and accidentally reverted this change.
Contributor
Author
|
Thanks @krzysdz for digging up the history, and @bjohansebas for merging. Worth recording that the credit for spotting it belongs to @marco-ippolito in #1474 — the fix was applied there and then lost to a force-push before merge. I only noticed the symptom. Glad it's back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
The open-redirect validation example on Production Best Practices: Security calls
new Url(req.query.url), but the JavaScript global isURL. As written the constructor throwsReferenceError: Url is not definedon every request, thecatchswallows it, and the handler responds400 "Unsupported redirect"for every URL — including valid ones — so the redirect never runs. Anyone copying the snippet gets a handler that silently rejects all redirects instead of validating them.One-line fix:
Url→URL.The same snippet appears in the translated mirrors, but per
docs/i18n.mdI've only touched the English source so Crowdin can propagate it.Verified locally:
npm run checkgreen, unit tests 52/52, and a fullastro buildsucceeds with the corrected snippet in the built page.