introduced default_protocol option which default to gemini, solving #21

This commit is contained in:
Ploum 2023-11-12 15:01:58 +01:00
parent b5640cc474
commit 63db80c7be
2 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@
Changes since beta2:
- bug #25 : makes python-requests optional again
- --disable-http had no effect: reimplemented
- introduced the "default_protocol" options (default to gemini) to enter URLs without the :// part (fixes bug #21)
## 2.0-beta2 - November 8th 2023
Changes since beta1

View File

@ -173,6 +173,7 @@ class GeminiClient(cmd.Cmd):
"wikipedia" : "gemini://vault.transjovian.org:1965/search/%s/%s",
"search" : "gemini://kennedy.gemi.dev/search?%s",
"accept_bad_ssl_certificates" : False,
"default_protocol" : "gemini",
}
self.redirects = offblocklist.redirects
for i in offblocklist.blocked:
@ -667,6 +668,9 @@ Use with "cache" to copy the path of the cached content."""
# If this isn't a mark, treat it as a URL
elif looks_like_url(line):
self._go_to_url(line)
elif "://" not in line and "default_protocol" in self.options.keys()\
and looks_like_url(self.options["default_protocol"]+"://"+line):
self._go_to_url(self.options["default_protocol"]+"://"+line)
else:
print("%s is not a valid URL to go"%line)