about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/config.md15
-rw-r--r--res/config.toml3
-rw-r--r--src/config/config.nim1
-rw-r--r--src/local/pager.nim5
4 files changed, 19 insertions, 5 deletions
diff --git a/doc/config.md b/doc/config.md
index 6633151c..1336f949 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -293,10 +293,21 @@ Network options are to be placed in the `[network]` section.
 </tr>
 
 <tr>
+<td>prepend-scheme</td>
+<td>string</td>
+<td>Prepend this to URLs passed to Chawan without a scheme.<br>
+Note that local files (`file:` scheme) will always be checked first; only
+if this fails, Chawan will retry the request with `prepend-scheme` set as
+the scheme.<br>
+By default, this is set to "https://". Note that the "://" part is
+mandatory.</td>
+</tr>
+
+<tr>
 <td>prepend-https</td>
 <td>boolean</td>
-<td>Whether or not Chawan should attempt loading "raw" URLs without a scheme as
-https (e.g. wikipedia.org as https://wikipedia.org.)</td>
+<td>Deprecated: use prepend-scheme instead.<br>
+When set to false, Chawan will act as if prepend-scheme were set to "".</td>
 </tr>
 
 <tr>
diff --git a/res/config.toml b/res/config.toml
index 3b4cefcd..85ac9aa8 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -37,7 +37,8 @@ cgi-dir = "${%CHA_LIBEXEC_DIR}/cgi-bin"
 
 [network]
 max-redirect = 10
-prepend-https = true
+prepend-scheme = "https://"
+prepend-https = true # deprecated, kept only for backwards-compatibility
 default-headers = {
 	User-Agent = "chawan",
 	Accept = "text/html,text/*;q=0.5",
diff --git a/src/config/config.nim b/src/config/config.nim
index 6500f73c..46ae2a08 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -101,6 +101,7 @@ type
   NetworkConfig = object
     max_redirect* {.jsgetset.}: int32
     prepend_https* {.jsgetset.}: bool
+    prepend_scheme* {.jsgetset.}: string
     proxy* {.jsgetset.}: Opt[string]
     default_headers* {.jsgetset.}: Table[string, string]
 
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 1da7797d..bf37b097 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -755,8 +755,9 @@ proc loadURL*(pager: Pager, url: string, ctype = none(string),
     pager.gotoURL(newRequest(firstparse.get), prev, ctype, cs)
     return
   var urls: seq[URL]
-  if pager.config.network.prepend_https and url[0] != '/':
-    let pageurl = parseURL("https://" & url)
+  if pager.config.network.prepend_https and
+      pager.config.network.prepend_scheme != "" and url[0] != '/':
+    let pageurl = parseURL(pager.config.network.prepend_scheme & url)
     if pageurl.isSome: # attempt to load remote page
       urls.add(pageurl.get)
   let cdir = parseURL("file://" & percentEncode(getCurrentDir(), LocalPathPercentEncodeSet) & DirSep)