mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-03 16:45:17 +03:00
feat(ports): add null checks for port name in short name generation
Add conditional checks to ensure `self._name` is not None before performing string operations in the `short_name` property. This prevents potential AttributeError exceptions when port name is undefined, improving robustness and compatibility with edge cases in port configuration.
This commit is contained in:
parent
4519130a8c
commit
f6777064db
@ -83,9 +83,9 @@ class Port:
|
||||
# If port name format has changed we use the port name as the short name (1.X behavior)
|
||||
if self._short_name:
|
||||
return self._short_name
|
||||
elif "/" in self._name:
|
||||
elif self._name and "/" in self._name:
|
||||
return self._name.replace(self.long_name_type(), self.short_name_type())
|
||||
elif self._name.startswith(f"{self.long_name_type()}{self._interface_number}"):
|
||||
elif self._name and self._name.startswith(f"{self.long_name_type()}{self._interface_number}"):
|
||||
return self.short_name_type() + f"{self._interface_number}"
|
||||
return self._name
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user