From 1653cf0d8894e82385ab08a3e0af8f794ecebbed Mon Sep 17 00:00:00 2001 From: Pipiche <8291674+pipiche38@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:00:06 +0100 Subject: [PATCH] Update DomoticzDB.py --- Classes/DomoticzDB.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Classes/DomoticzDB.py b/Classes/DomoticzDB.py index 655709dbe..5afa3a245 100644 --- a/Classes/DomoticzDB.py +++ b/Classes/DomoticzDB.py @@ -79,6 +79,9 @@ def extract_username_password(self, url_base_api): :param url_base_api: The URL containing credentials in the format ://:@ :return: A tuple (username, password, host_port, proto) or (None, None, None, None) if invalid. """ + HTTP_PROTO = "http://" # noqa: S5332 + HTTPS_PROTO = "https://" + items = url_base_api.split('@') if len(items) != 2: self.logging("Debug", f"no credentials in the URL: {url_base_api}") @@ -88,10 +91,10 @@ def extract_username_password(self, url_base_api): proto = None credentials, host_port = items - if credentials.startswith("https://"): + if credentials.startswith(HTTPS_PROTO): proto = "https" credentials = credentials[8:] # Remove proto - elif credentials.startswith("http://"): # noqa: S5332 + elif credentials.startswith(HTTP_PROTO): proto = "http" credentials = credentials[7:] # Remove proto else: