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

router: Fix missing requirement checks for regex routes #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sanic_routing/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ def _render(
route_idx: t.Union[str, int] = 0
holder: t.List[Line] = []

if len(group.routes) > 1:
if group.requirements:
route_idx = "route_idx"
Node._inject_requirements(holder, 2, group)
elif len(group.routes) > 1:
route_idx = "route_idx"
Node._inject_method_check(holder, 2, group)

Expand Down
3 changes: 2 additions & 1 deletion sanic_routing/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ def _inject_return(self, location, indent, route_idx, group):
]
)

def _inject_requirements(self, location, indent, group):
@staticmethod
def _inject_requirements(location, indent, group):
"""
Check any extra checks needed for a route. In path routing, for exampe,
this is used for matching vhosts.
Expand Down