[damned-lies] Allow branch names with slashes



commit fc87636fab14c4c33f7b43b6757ab8dda1d0ae1a
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Nov 23 14:58:34 2019 +0100

    Allow branch names with slashes

 damnedlies/urls.py   | 6 +++---
 stats/tests/tests.py | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/damnedlies/urls.py b/damnedlies/urls.py
index 5fd6b246..6384a596 100644
--- a/damnedlies/urls.py
+++ b/damnedlies/urls.py
@@ -24,7 +24,7 @@ class NameConverter(StringConverter):
 
 register_converter(LocaleConverter, 'locale')
 register_converter(NameConverter, 'name')
-module_branch_domain = '<name:module_name>/<name:branch_name>/<name:domain_name>'
+module_branch_domain = '<name:module_name>/<path:branch_name>/<name:domain_name>'
 
 urlpatterns = [
     path('',
@@ -93,13 +93,13 @@ urlpatterns += [
     path('module/<name:module_name>/edit/branches/',
          stats_views.module_edit_branches,
          name='module_edit_branches'),
-    path('module/<name:module_name>/branch/<name:branch_name>/',
+    path('module/<name:module_name>/branch/<path:branch_name>/',
          stats_views.module_branch,
          name='module_branch'),
     path('branch/<int:branch_id>/refresh/',
          stats_views.branch_refresh,
          name='branch_refresh'),
-    path('module/<name:module_name>/<name:potbase>/<name:branch_name>/<locale:langcode>/images/',
+    path('module/<name:module_name>/<name:potbase>/<path:branch_name>/<locale:langcode>/images/',
          stats_views.docimages,
          name='docimages'),
     re_path(r'^releases/(?P<format>(html|json|xml))?/?$',
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 05340064..f0c14c35 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -77,6 +77,9 @@ class ModuleTestCase(TestCase):
         # Missing branch
         response = self.client.get(reverse('module_branch', args=['gnome-hello', 'missing']))
         self.assertEqual(response.status_code, 404)
+        # Branch name with slash is reverse-able
+        response = self.client.get(reverse('module_branch', args=['gnome-hello', 'with/slash']))
+        self.assertEqual(response.status_code, 404)
 
     def test_module_bugs_reporting(self):
         response = self.client.get(reverse('module', args=[self.mod.name]))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]