add missing schema in utils.http.sanitise_url, use in rss.py
This commit is contained in:
parent
1def848233
commit
078681eddf
2 changed files with 5 additions and 2 deletions
|
@ -103,7 +103,7 @@ class Module(ModuleManager.BaseModule):
|
|||
if not len(event["args_split"]) > 1:
|
||||
raise utils.EventError("Please provide a URL")
|
||||
|
||||
url = event["args_split"][1]
|
||||
url = utils.http.url_sanitise(event["args_split"][1])
|
||||
if url in rss_hooks:
|
||||
raise utils.EventError("That URL is already being watched")
|
||||
|
||||
|
@ -119,7 +119,7 @@ class Module(ModuleManager.BaseModule):
|
|||
if not len(event["args_split"]) > 1:
|
||||
raise utils.EventError("Please provide a URL")
|
||||
|
||||
url = event["args_split"][1]
|
||||
url = utils.http.url_sanitise(event["args_split"][1])
|
||||
if not url in rss_hooks:
|
||||
raise utils.EventError("I'm not watching that URL")
|
||||
rss_hooks.remove(url)
|
||||
|
|
|
@ -9,6 +9,9 @@ REGEX_URL = re.compile("https?://[A-Z0-9{}]+".format(re.escape("-._~:/%?#[]@!$&'
|
|||
|
||||
# best-effort tidying up of URLs
|
||||
def url_sanitise(url: str):
|
||||
if not urllib.parse.urlparse(url).scheme:
|
||||
url = "http://%s" % url
|
||||
|
||||
if url.endswith(")"):
|
||||
# trim ")" from the end only if there's not a "(" to match it
|
||||
# google.com/) -> google.com/
|
||||
|
|
Loading…
Reference in a new issue