From 0b1cc52fbdeba4cb9bc8130a27b043aed935bf4c Mon Sep 17 00:00:00 2001 From: Tremolo4 Date: Sat, 24 Jul 2021 04:26:28 +0200 Subject: [PATCH] Trusted Domains: strip HTTP basic auth credentials also when adding as trusted domain via context menu --- syncplay/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/syncplay/utils.py b/syncplay/utils.py index 5a394d3..bfc788c 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -395,12 +395,15 @@ def playlistIsValid(files): def getDomainFromURL(URL): try: - URL = URL.split("//")[-1].split("/")[0] - if URL.startswith("www."): - URL = URL[4:] - return URL - except: + o = urllib.parse.urlparse(URL) + except ValueError: + # not a URL return None + if o.hostname is not None and o.hostname.startswith("www."): + return o.hostname[4:] + else: + # may return None if URL does not have domain (invalid url) + return o.hostname def open_system_file_browser(path):