about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-14 10:39:39 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-14 10:39:39 +0100
commit03480fea95101cf1147c1e1a65c4e6fb457b1402 (patch)
treea0df53f52a65ae7cdecfeb83e8aa3c900579b665 /src
parent0f3577949819daa31fbf8cd943d634f49d35c498 (diff)
downloadchawan-03480fea95101cf1147c1e1a65c4e6fb457b1402.tar.gz
Fix search
Diffstat (limited to 'src')
-rw-r--r--src/config/config.nim3
-rw-r--r--src/display/pager.nim6
2 files changed, 7 insertions, 2 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 220b3948..4ab2d49b 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -368,8 +368,9 @@ proc parseConfig(config: Config, dir: string, t: TomlValue) =
           for k, v in v:
             case k
             of "match": rule.match = v.s
-            of "substitute": rule.subst = v.s
+            of "substitute-url": rule.subst = v.s
           if rule.match != "":
+            assert rule.subst != "", "Unspecified substitution for rule " & rule.match
             config.omnirules.add(rule)
 
 proc parseConfig(config: Config, dir: string, stream: Stream) =
diff --git a/src/display/pager.nim b/src/display/pager.nim
index 9837d2fa..9c3e664b 100644
--- a/src/display/pager.nim
+++ b/src/display/pager.nim
@@ -532,7 +532,11 @@ proc gotoURL*(pager: Pager, request: Request, prevurl = none(URL),
 proc omniRewrite(pager: Pager, s: string): string =
   for rule in pager.omnirules:
     if rule.match.match(s):
-      return rule.subst(s).get
+      let sub = rule.subst(s)
+      if sub.isSome:
+        return sub.get
+      else:
+        pager.alert("Error in substitution of rule " & rule.match.buf & " for " & s)
   return s
 
 # When the user has passed a partial URL as an argument, they might've meant