fixing a bug where mailto: url were not counted as URL in a page
This commit is contained in:
parent
f2944d35af
commit
b611c1ec87
|
@ -156,6 +156,8 @@ urllib.parse.uses_relative.append("gemini")
|
||||||
urllib.parse.uses_netloc.append("gemini")
|
urllib.parse.uses_netloc.append("gemini")
|
||||||
|
|
||||||
def fix_ipv6_url(url):
|
def fix_ipv6_url(url):
|
||||||
|
if not url:
|
||||||
|
return
|
||||||
if not url.count(":") > 2: # Best way to detect them?
|
if not url.count(":") > 2: # Best way to detect them?
|
||||||
return url
|
return url
|
||||||
# If there's a pair of []s in there, it's probably fine as is.
|
# If there's a pair of []s in there, it's probably fine as is.
|
||||||
|
@ -729,10 +731,13 @@ def looks_like_url(word):
|
||||||
parsed = urllib.parse.urlparse(url)
|
parsed = urllib.parse.urlparse(url)
|
||||||
#sometimes, urllib crashed only when requesting the port
|
#sometimes, urllib crashed only when requesting the port
|
||||||
port = parsed.port
|
port = parsed.port
|
||||||
|
mailto = word.startswith("mailto:")
|
||||||
start = word.startswith("gemini://") or word.startswith("http://")\
|
start = word.startswith("gemini://") or word.startswith("http://")\
|
||||||
or word.startswith("https://")
|
or word.startswith("https://")
|
||||||
if not start:
|
if not start and not mailto:
|
||||||
return looks_like_url("gemini://"+word)
|
return looks_like_url("gemini://"+word)
|
||||||
|
elif mailto:
|
||||||
|
return "@" in word
|
||||||
else:
|
else:
|
||||||
return "." in word
|
return "." in word
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue