Skip to content

Commit

Permalink
Update DomoticzDB.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 authored Jan 14, 2025
1 parent f2d4898 commit 1653cf0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/DomoticzDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def extract_username_password(self, url_base_api):
:param url_base_api: The URL containing credentials in the format <proto>://<username>:<password>@<host>
: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}")
Expand All @@ -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:
Expand Down

0 comments on commit 1653cf0

Please sign in to comment.