Skip to content

Can't use ()? in regex path definition #24

@vincentsarago

Description

@vincentsarago
@app.route( 
    r"/test/<regex(user(\d+)?):user>/<sport>" ) 
def test(user, sport): 
    return ("OK", "text/plain", "YO")

this will fail here

def _get_matching_args(self, route: RouteEntry, url: str) -> Dict:
route_expr = re.compile(route.route_regex)
route_args = [i.group() for i in params_expr.finditer(route.path)]
url_args = route_expr.match(url).groups()
names = [param_pattern.match(arg).groupdict()["name"] for arg in route_args]
args = [
_converters(u, route_args[id])
for id, u in enumerate(url_args)
if u != route_args[id]
]

because url_args = route_expr.match(url).groups() will return ('user1234', '1234', 'rugby')

fix

Use patterns ?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions