Whole file
sanic-org/sanic-routing
The author described this change as “Fix routing with multiple routes contain 'path' params (#49)”. It counts as a record because the check below fails on the code as it stood at 0c6c860ef and passes on 4df3d82b4, with nothing else changed between the two runs.
Projectsanic-org/sanic-routing
Fix saved2021-11-04
Sharing licenceMIT · LICENSE
Change size+3 −1
What the code was meant to do, written into the code itself as a save note
Fix routing with multiple routes contain 'path' params (#49)
The change
| 423 | 423 | "regex_routes" if group.regex else "dynamic_routes" | |
| 424 | 424 | ) | |
| 425 | 425 | route_idx: t.Union[str, int] = 0 | |
| 426 | + | holder: t.List[Line] = [] | |
| 426 | 427 | ||
| 427 | 428 | if len(group.routes) > 1: | |
| 428 | 429 | route_idx = "route_idx" | |
| 429 | - | Node._inject_method_check(src, 1, group) | |
| 430 | + | Node._inject_method_check(holder, 2, group) | |
| 430 | 431 | ||
| 431 | 432 | src.extend( | |
| 432 | 433 | [ | |
| ⋯ | |||
| 438 | 439 | 1, | |
| 439 | 440 | ), | |
| 440 | 441 | Line("if match:", 1), | |
| 442 | + | *holder, | |
| 441 | 443 | Line("basket['__params__'] = match.groupdict()", 2), | |
| 442 | 444 | Line( | |
| 443 | 445 | ( | |
The check that tells the two apart
fail→pass·tests/test_routing.py::test_identical_path_routes_with_different_methods_similar_urls[a-random-path]
Check file tests/test_routing.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it0c6c860ef8507f77eba7d039fbc713ab2a7f0e56
Broken version dated2021-07-01
Modulesanic_routing.router
Units changedBaseRouter
Fingerprinte21d218202558db5
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in sanic-org/sanic-routing
- 2021-03-25Fix routes with different depth (#13)
- 2021-03-04Resolve requirements conditional bug (#6)