Skip to content

Commit

Permalink
Fixes: #13722 - Correct range expansion code when a numeric set is used
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps committed Feb 28, 2024
1 parent edb7d24 commit 017a66b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion netbox/utilities/forms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
11 changes: 10 additions & 1 deletion netbox/utilities/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,16 @@ def test_range_alpha(self):

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',
Expand Down

0 comments on commit 017a66b

Please sign in to comment.