1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

fix scope matching issue

This commit is contained in:
Kelly Brazil
2022-07-28 15:42:25 -07:00
parent 1fcf844e8d
commit 24960cd02b

View File

@ -545,12 +545,14 @@ def parse(
# python versions < 3.9 do not handle the ipv6 scope, so pop it # python versions < 3.9 do not handle the ipv6 scope, so pop it
# and use instead of ipaddress.scope_id if parsing fails # and use instead of ipaddress.scope_id if parsing fails
scope_string = None scope_string = None
try: try:
interface = ipaddress.ip_interface(data) interface = ipaddress.ip_interface(data)
except ValueError: except ValueError:
scope_match = re.match(SCOPE_PATTERN, data) scope_match = re.search(SCOPE_PATTERN, data)
if scope_match: if scope_match:
scope_string = scope_match.group(0) scope_string = scope_match.group(0)[1:]
data = re.sub(SCOPE_PATTERN, '', data) data = re.sub(SCOPE_PATTERN, '', data)
interface = ipaddress.ip_interface(data) interface = ipaddress.ip_interface(data)