From 03480fea95101cf1147c1e1a65c4e6fb457b1402 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 14 Dec 2022 10:39:39 +0100 Subject: Fix search --- src/config/config.nim | 3 ++- src/display/pager.nim | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit 1.4.1-2-gfad0