diff --git a/netbox/utilities/forms/utils.py b/netbox/utilities/forms/utils.py index 689fbebbf..005b8be85 100644 --- a/netbox/utilities/forms/utils.py +++ b/netbox/utilities/forms/utils.py @@ -60,7 +60,7 @@ def parse_alphanumeric_range(string): return [] except ValueError: begin, end = dash_range, dash_range - if begin.isdigit() and end.isdigit(): + if begin.isdigit() and end.isdigit() and not begin == end: if int(begin) >= int(end): raise forms.ValidationError(_('Range "{value}" is invalid.').format(value=dash_range)) diff --git a/netbox/utilities/tests/test_forms.py b/netbox/utilities/tests/test_forms.py index d014d4bbd..aab9af870 100644 --- a/netbox/utilities/tests/test_forms.py +++ b/netbox/utilities/tests/test_forms.py @@ -191,7 +191,16 @@ class ExpandAlphanumeric(TestCase): self.assertEqual(sorted(expand_alphanumeric_pattern(input)), output) - def test_set(self): + def test_set_numeric(self): + input = 'r[1,2]a' + output = sorted([ + 'r1a', + 'r2a', + ]) + + self.assertEqual(sorted(expand_alphanumeric_pattern(input)), output) + + def test_set_alpha(self): input = '[r,t]1a' output = sorted([ 'r1a',