Skip to content

Commit 8da5426

Browse files
committed
Add maxsize split on segment definition
1 parent e274b6c commit 8da5426

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

sanic_routing/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from .route import Route
33
from .router import BaseRouter
44

5-
__version__ = "0.6.0"
5+
__version__ = "0.6.1"
66
__all__ = ("BaseRouter", "Route", "RouteGroup")

sanic_routing/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def _sorting(item) -> t.Tuple[bool, int, str, bool, int]:
317317
if child.dynamic:
318318
key = key[1:-1]
319319
if ":" in key:
320-
key, param_type = key.split(":")
320+
key, param_type = key.split(":", 1)
321321
try:
322322
type_ = list(REGEX_TYPES.keys()).index(param_type)
323323
except ValueError:

tests/test_routing.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from datetime import date
33

44
import pytest
5-
65
from sanic_routing import BaseRouter
76
from sanic_routing.exceptions import NoMethod, NotFound, RouteExists
87

@@ -376,3 +375,24 @@ def handler2():
376375
_, handler, params = router.get("/test/ing/", "BASE")
377376
assert handler() == "handler2"
378377
assert params == {"foo": "test"}
378+
379+
380+
def test_path_with_paamayim_nekudotayim():
381+
def handler(**kwargs):
382+
return kwargs
383+
384+
router = Router()
385+
router.add(
386+
r"/path/to/<file_uuid:(?P<file_uuid>[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12})(?:\.[A-z]{1,4})?>",
387+
handler,
388+
)
389+
390+
router.finalize()
391+
392+
print(router.find_route_src)
393+
394+
_, handler, params = router.get(
395+
"/path/to/726a7d33-4bd5-46a3-a02d-37da7b4b029b.jpeg", "BASE"
396+
)
397+
assert handler(**params) == params
398+
assert params == {"file_uuid": "726a7d33-4bd5-46a3-a02d-37da7b4b029b"}

0 commit comments

Comments
 (0)