-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
url_for() doesn't return a working URI for a route with the trailing slash and strict_slashes=True #1420
Comments
I confirmed the behavior. @hatarist Do you think you could take a swing at a PR? |
To be honest, I was never a fan of the My only concern is that the Sanic router doesn't actually save on IMHO, to fix this, we might need to add more complexity to the router (saving the actual value of As a matter of fact, looking closely, I don't think the Router may even care about the |
@vltr I agree with you on the amount of changes required to address this the right way. However, the current implementation contradicts with the I believe it might be a good idea to move the Route namedtuple into a class of it's own with When I was looking at the router to add this comment, I noticed that the current implementation we have for |
+1 I like this idea @harshanarayana Without sidetracking this conversation too much ... Let's open this discussion on the forums about what to do with the router. The December release is coming up fast, and if we want to have a chance at putting in a new router implementation (or resolving some of the existing issues) by March, let's make some decisions soon. |
@ahopkins @vltr If everyone is okay with it, the quick way to fix this issue without changing too much and the core router implementation is to remove the forced removal of the trailing The last and not so good way to fix is to leverage the |
I agree with @ahopkins to take this discussion to the community forums. We can also take the discussion on #1386 regarding routing there as well - @hatarist I think you will be onboard since you gave a lot of insigts on the related issue. Just a couple of notes here:
Indeed, this is something that will need a lot of attention to fix "sanic-wise".
That I couldn't agree more. Interacting with the
I don't think we should do any quick fix presuming this or that because it will eventually fail 😔
I don't like this option either: the developer will end up setting |
@ahopkins Anyone already is working on it? if not, I'll be happy to work on it. |
@MichaelYusko I think we need to take this matter to the forums for a better discussion, because the "correct way" of fixing this is way bellow the |
@vltr Thanks, okay will jump into the forum;) |
@MichaelYusko actually we need to create that discussion in the forum ... Oh my. Sorry, my head is over the clouds today. |
I'll start the discussion and post the link here ASAP ... |
@vltr Gotcha, no worries;) start of the week is always hard ;-) |
@MichaelYusko yeah, sort of ... Busy day in here. Also, @hatarist @ahopkins @harshanarayana take a look at the community forums for that matter. |
@vltr which a status of the issue? |
@5onic No one is working on anything router related right now (as far as I know... after I am done with ASGI, I want to turn some attention to it). Feel free to make the PR. This is also a question whether @huge-success/sanic-core-devs think this is something that we should also patch 18.12LTS. |
@ahopkins Cool, I'll start work on it in 3-4 days. |
What happened to this? Trailing slashes still go missing. |
Describe the bug
Say we have a route with the trailing slash and
strict_slashes=True
:@app.route('/endpoint/', strict_slashes=True)
this way,
url_for()
will always trim the trailing slash, returning a non-working URL.Code snippet
Expected behavior
In my example,
request.app.url_for('endpoint')
is expected to return'/endpoint/'
.Environment (please complete the following information):
Additional context
The current implementation of
url_for()
just blindly removes the trailing slash, see app.py, lines 617-618.The text was updated successfully, but these errors were encountered: