-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Expose new path used to compute new url in RequestRedirect #3000
Comments
When we raise the RequestRedirect exception we have already computed the new url that should be redirected to in the exception (new_url) but we don't pass the the new path that we used to compute the url. This causes another layer of redirection in depending code that needs to urlparse() the url to get the path we already have the data for. This adds new_path to the RequestRedirect exception and populates it with the path used when computing new_url. Fixes: pallets#3000
When we raise the RequestRedirect exception we have already computed the new url that should be redirected to in the exception (new_url) but we don't pass the the new path that we used to compute the url. This causes another layer of redirection in depending code that needs to urlparse() the url to get the path we already have the data for. This adds new_path to the RequestRedirect exception and populates it with the path used when computing new_url. Fixes: pallets#3000
In what situation do you need this? |
In this case it's a WSGI middleware that uses werkzeg's routing module for matching routes to know when to apply a specific logic. The module does a great job to match URLs but we need to handle cases where URLs contain a trailing slash or double slashes in the middle of the URL. Example: Lets say we want to match |
You could disable If you're calling |
This is how the
|
The RequestRedirect exception is raised with new_url set to
the computed URL that should be redirected to, but we don't
expose the path that was used to compute the URL in the exception
so depending code needs to urlparse() the URL even though
werkzeug already has the path and can pass it along in the exception.
Referring to this example code:
The text was updated successfully, but these errors were encountered: