From 330cddc1c741a95d7e2216d600329c8d4bd0abde Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 17 2018 12:48:03 +0000 Subject: Fix the RELATES regex as we fixed the FIXES ones Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/link.py b/pagure/lib/link.py index a8afc12..5a61218 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -36,7 +36,7 @@ RELATES = [ re.compile(r'(?:.*\s+)?relate[sd]?:?\s?#(\d+)', re.I), re.compile( r'(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?' - 'https?://.*/(\w+)/issue/(\d+)', re.I), + 'https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)/issue/(\d+)', re.I), ] diff --git a/tests/test_pagure_lib_link.py b/tests/test_pagure_lib_link.py index 6c60ad1..4dcb4ab 100644 --- a/tests/test_pagure_lib_link.py +++ b/tests/test_pagure_lib_link.py @@ -221,6 +221,13 @@ class PagureLibLinktests(tests.Modeltests): else: self.assertEqual(regex.match(text), None) + text = 'relates https://localhost/SSSD/ding-libs/issue/31' + for index, regex in enumerate(pagure.lib.link.RELATES): + if index == 2: + self.assertNotEqual(regex.match(text), None) + else: + self.assertEqual(regex.match(text), None) + def test_fixes_regex(self): ''' Test the fixes regex present in pagure.lib.link. '''