about summary refs log tree commit diff stats
path: root/src/client.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.nim')
-rw-r--r--src/client.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client.nim b/src/client.nim
index 3ee26609..66cd0c41 100644
--- a/src/client.nim
+++ b/src/client.nim
@@ -143,11 +143,17 @@ proc loadUrl(client: Client, url: string, ctype = "") =
   if firstparse.issome:
     client.gotoUrl(url, none(ClickAction), none(Url), true, true, ctype)
   else:
+    let cdir = parseUrl("file://" & getCurrentDir() & DirSep)
     try:
-      let cdir = parseUrl("file://" & getCurrentDir() & DirSep)
+      # attempt to load local file
       client.gotoUrl(url, none(ClickAction), cdir, true, true, ctype)
     except LoadError:
-      client.gotoUrl("http://" & url, none(ClickAction), none(Url), true, true, ctype)
+      try:
+        # attempt to load local file (this time percent encoded)
+        client.gotoUrl(percentEncode(url, LocalPathPercentEncodeSet), none(ClickAction), cdir, true, true, ctype)
+      except LoadError:
+        # attempt to load remote page
+        client.gotoUrl("http://" & url, none(ClickAction), none(Url), true, true, ctype)
 
 proc reloadPage(client: Client) =
   client.gotoUrl(client.buffer.location, none(ClickAction), none(Url), true, false, client.buffer.contenttype)