Skip to content
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

Fixed URLRouter root_path handling. #1954

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

asedeno
Copy link
Contributor

@asedeno asedeno commented Nov 16, 2022

As discussed in django/daphne#125, this adds handing of scope["root_path"] to channels.routing.URLRouter.

root_path = scope.get("root_path", "")
if root_path and not path.startswith(root_path):
# If root_path is present, path must start with it.
raise ValueError("No route found for path %r." % path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably mention root_path as well, but I was not sure how best to phrase it. Suggestions welcome.

@tevariou
Copy link

tevariou commented Apr 2, 2024

any news on when this could be merged ?

@carltongibson
Copy link
Member

@tevariou It's on my list to review now.

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
If we have a scope["root_path"], raise if it does not prefix
scope["path"], and strip it from scope["path"] if it does. Do this
only if we're in an outermost URLRouter.

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
@carltongibson carltongibson changed the title Handle root path Fixed URLRouter root_path handling. Apr 3, 2024
Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I finally got to it. Thanks @asedeno, and thanks for your patience.

@carltongibson carltongibson merged commit 82c26f2 into django:main Apr 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants