aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-08-02 23:33:28 +0200
committerbptato <nincsnevem662@gmail.com>2022-08-02 23:33:53 +0200
commitec26d22cedb03fd8a03c110fad6b6a91c444329b (patch)
treea062b2995707379f2be6a92a3b8dcc6bc5fa7ff6 /src
parent7de898bd05fd54f216009ebc3775a007fd92c417 (diff)
downloadchawan-ec26d22cedb03fd8a03c110fad6b6a91c444329b.tar.gz
Fix non-special url scheme parsing
Diffstat (limited to 'src')
-rw-r--r--src/client.nim8
-rw-r--r--src/types/url.nim3
2 files changed, 6 insertions, 5 deletions
diff --git a/src/client.nim b/src/client.nim
index 4d7fc2f4..7bb0721e 100644
--- a/src/client.nim
+++ b/src/client.nim
@@ -205,11 +205,11 @@ proc gotoUrl(client: Client, url: string, click = none(ClickAction), prevurl = n
client.gotoUrl(newurl.get, click, prevurl, force, ctype)
# When the user has passed a partial URL as an argument, they might've meant
-# several things:
-# * the URL as it is
+# either:
# * file://$PWD/<file>
# * https://<url>
-# So we attempt to visit each of them, in the order described above.
+# So we attempt to load both, and see what works.
+# (TODO: make this optional)
proc loadUrl(client: Client, url: string, ctype = "") =
let firstparse = parseUrl(url)
if firstparse.issome:
@@ -225,7 +225,7 @@ proc loadUrl(client: Client, url: string, ctype = "") =
client.gotoUrl(percentEncode(url, LocalPathPercentEncodeSet), none(ClickAction), cdir, true, ctype)
except LoadError:
# attempt to load remote page
- client.gotoUrl("http://" & url, none(ClickAction), none(Url), true, ctype)
+ client.gotoUrl("https://" & url, none(ClickAction), none(Url), true, ctype)
# Reload the page in a new buffer, then kill the previous buffer.
proc reloadPage(client: Client) =
diff --git a/src/types/url.nim b/src/types/url.nim
index 7f41025b..fd1aa201 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -389,6 +389,7 @@ proc basicParseUrl*(input: string, base = none(Url), url: var Url = Url(), overr
state = SPECIAL_AUTHORITY_SLASHES_STATE
elif has(1) and c(1) == '/':
state = PATH_OR_AUTHORITY_STATE
+ inc pointer
else:
url.path = EmptyPath
state = OPAQUE_PATH_STATE
@@ -554,7 +555,7 @@ proc basicParseUrl*(input: string, base = none(Url), url: var Url = Url(), overr
#TODO validation error
return none(Url)
let port = cast[uint16](i).some
- url.port = if url.default_port == port: none(uint16) else: port
+ url.port = if url.is_special and url.default_port == port: none(uint16) else: port
buffer = ""
if override:
return