Regexp fix
This commit is contained in:
1 parent
a0f73a0e05
commit
922034315e
2 files changed
+2
-3
No files matched your search
@@ -50,6 +50,6 @@ class DestinationPrefixOwner(permissions.BasePermission):
|
||||
if len(my_prefixes) == 0:
|
||||
return False
|
||||
# Prepare regular expression
|
||||
regexp = '|'.join(['{0}-'.format(p) for p in my_prefixes])
|
||||
regexp = '|'.join(['^{0}-'.format(p) for p in my_prefixes])
|
||||
# The destination should have at least one match with the prefix regexp
|
||||
return re.search(regexp, fw.data['dest']) is not None
|
||||
+1
-2
@@ -67,8 +67,7 @@ class ForwardsViewSet(viewsets.ViewSet):
|
||||
|
||||
my_prefixes = orgunits.values_list('prefix', flat=True)
|
||||
# Prepare regular expression
|
||||
regexp = '|'.join(['{0}-'.format(p) for p in my_prefixes])
|
||||
|
||||
regexp = '|'.join(['^{0}-'.format(p) for p in my_prefixes])
|
||||
if len(my_prefixes) == 0:
|
||||
return Response({'result': 'No results'}) # Need at least one
|
||||
|
||||
|
||||
Reference in new issue
Block a user