From a4ce0cb039a24ebee86d7ff0cabe620ff0ab3f3c Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 18 Jan 2021 22:33:50 +0000 Subject: [PATCH] fix: support another slug pattern --- django_codemod/visitors/urls.py | 1 + tests/visitors/test_urls.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/django_codemod/visitors/urls.py b/django_codemod/visitors/urls.py index 8fbb2187..2b700162 100644 --- a/django_codemod/visitors/urls.py +++ b/django_codemod/visitors/urls.py @@ -19,6 +19,7 @@ class PatternNotSupported(RuntimeError): ".+": "path", "[-a-zA-Z0-9_]+": "slug", r"[\w-]+": "slug", + r"[-\w]+": "slug", "[^/]+": "str", "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}": "uuid", } diff --git a/tests/visitors/test_urls.py b/tests/visitors/test_urls.py index 77758899..a9715574 100644 --- a/tests/visitors/test_urls.py +++ b/tests/visitors/test_urls.py @@ -129,6 +129,7 @@ def test_grouped_path(self) -> None: url(r'^page/(?P\d+)/$', views.page, name='page'), url(r'^post/(?P[-a-zA-Z0-9_]+)/$', views.post, name='post'), url(r'^post/(?P[\w-]+)/$', views.post, name='post'), + url(r'^post/(?P[-\w]+)/$', views.post, name='post'), url(r'^about/(?P[^/]+)/$', views.about, name='about'), url(r'^uuid/(?P{uuid_re})/$', by_uuid), url(r'^(?P.+)/$', views.default, name='default'), @@ -142,6 +143,7 @@ def test_grouped_path(self) -> None: path('page//', views.page, name='page'), path('post//', views.post, name='post'), path('post//', views.post, name='post'), + path('post//', views.post, name='post'), path('about//', views.about, name='about'), path('uuid//', by_uuid), path('/', views.default, name='default'),