-
Notifications
You must be signed in to change notification settings - Fork 27
Normalize URL handling #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| }), | ||
| body: req.payload, | ||
| url: req.url.toString(), | ||
| url: req.raw?.req ? getRequestUrl(req.raw?.req) : partialUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed computation of exported Context.url (now may return a different absolute form), which can break clients expecting the previous req.url.toString() value.
Details
✨ AI Reasoning
1) The code constructs a Context object from an incoming Hapi Request; the PR changes how the url field is computed (now using getRequestUrl(req.raw?.req) when available) and adds a new urlPath field.
2) This alters the semantic value of the exported context.url property (previously always req.url.toString()), which can change downstream behavior for any consumers relying on the old absolute/relative form.
3) Adding urlPath is additive and safe, but changing the existing url value is a breaking contract for clients that expect the previous format.
🔧 How do I fix it?
Support both old and new parameter names during transition periods. Add new optional parameters with defaults. Keep existing response fields while adding new ones. Focus on backwards compatibility.
More info - Comment @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
We always want to use the full absolute URL including the host and different formats depending on the framework.
We also want to respect proxy headers if the proxy is trusted.
We also need to add the path to the context!! ✅