From cfc3bd77b5b6c969c8e5b5a8daebef361fab51f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 6 Jul 2023 05:54:09 +0200 Subject: [PATCH] Continued: - cut out ' - ' only if found --- fba/helpers/software.py | 3 ++- fba/helpers/version.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index 266a6dd..31224b4 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -55,7 +55,8 @@ def alias(software: str) -> str: elif "powered by" in software: logger.debug("software='%s' has 'powered by' in it", software) software = version.strip_powered_by(software) - elif isinstance(software, str) and " by " in software: + + if isinstance(software, str) and " by " in software: logger.debug("software='%s' has ' by ' in it", software) software = version.strip_until(software, " by ") elif isinstance(software, str) and " - " in software: diff --git a/fba/helpers/version.py b/fba/helpers/version.py index 19ad520..2ea6219 100644 --- a/fba/helpers/version.py +++ b/fba/helpers/version.py @@ -101,7 +101,8 @@ def strip_powered_by(software: str) -> str: software = software[start + 11:].strip() logger.debug("software='%s'", software) - software = strip_until(software, " - ") + if " - " in software: + software = strip_until(software, " - ") logger.debug("software='%s' - EXIT!", software) return software @@ -122,7 +123,8 @@ def strip_hosted_on(software: str) -> str: software = software[0:end].strip() logger.debug("software[%s]='%s'", type(software), software) - software = strip_until(software, " - ") + if " - " in software: + software = strip_until(software, " - ") logger.debug("software='%s' - EXIT!", software) return software -- 2.39.5