2222example_url_conf = (
2323 url (r"^api/(?P<project_id>[\w_-]+)/store/$" , lambda x : "" ),
2424 url (r"^api/(?P<version>(v1|v2))/author/$" , lambda x : "" ),
25+ url (
26+ r"^api/(?P<project_id>[^\/]+)/product/(?P<pid>(?:\d+|[A-Fa-f0-9-]{32,36}))/$" ,
27+ lambda x : "" ,
28+ ),
2529 url (r"^report/" , lambda x : "" ),
2630 url (r"^example/" , include (included_url_conf )),
27- url (
28- r"^(?P<slug>[$\\-_.+!*(),\\w//]+)/$" , lambda x : ""
29- ), # example of complex regex from django-cms
3031)
3132
3233
@@ -56,14 +57,12 @@ def test_legacy_resolver_included_match():
5657 assert result == "/example/foo/bar/{param}"
5758
5859
59- def test_complex_regex_from_django_cms ():
60- """
61- Reference: https://github.com/getsentry/sentry-python/issues/1527
62- """
63-
60+ def test_capture_multiple_named_groups ():
6461 resolver = RavenResolver ()
65- result = resolver .resolve ("/,/" , example_url_conf )
66- assert result == "/{slug}/"
62+ result = resolver .resolve (
63+ "/api/myproject/product/cb4ef1caf3554c34ae134f3c1b3d605f/" , example_url_conf
64+ )
65+ assert result == "/api/{project_id}/product/{pid}/"
6766
6867
6968@pytest .mark .skipif (django .VERSION < (2 , 0 ), reason = "Requires Django > 2.0" )
@@ -74,3 +73,13 @@ def test_legacy_resolver_newstyle_django20_urlconf():
7473 resolver = RavenResolver ()
7574 result = resolver .resolve ("/api/v2/1234/store/" , url_conf )
7675 assert result == "/api/v2/{project_id}/store/"
76+
77+
78+ @pytest .mark .skipif (django .VERSION < (2 , 0 ), reason = "Requires Django > 2.0" )
79+ def test_legacy_resolver_newstyle_django20_urlconf_multiple_groups ():
80+ from django .urls import path
81+
82+ url_conf = (path ("api/v2/<int:project_id>/product/<int:pid>" , lambda x : "" ),)
83+ resolver = RavenResolver ()
84+ result = resolver .resolve ("/api/v2/1234/product/5689" , url_conf )
85+ assert result == "/api/v2/{project_id}/product/{pid}"
0 commit comments