diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-02 13:13:14 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-02 13:27:06 +0200 |
commit | b1fde40677d0cfeb5a5c28bdd0aeca775b6aa0e1 (patch) | |
tree | 4572f7d2216cc9ed03670bcee0cb6c39a4cf4936 /src/config | |
parent | 70eccee7bcdc5486cfb339c95f8995970a2f41d1 (diff) | |
download | chawan-b1fde40677d0cfeb5a5c28bdd0aeca775b6aa0e1.tar.gz |
return Result[T, JSError] from fromJS
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/config.nim | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index 7fc0b2b1..1bfacd28 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -45,7 +45,7 @@ type SiteConfig* = object url*: Opt[Regex] host*: Opt[Regex] - rewrite_url*: (proc(s: URL): Opt[URL]) + rewrite_url*: (proc(s: URL): Result[URL, JSError]) cookie*: Opt[bool] third_party_cookie*: seq[Regex] share_cookie_jar*: Opt[string] @@ -57,7 +57,7 @@ type OmniRule* = object match*: Regex - substitute_url*: (proc(s: string): Opt[string]) + substitute_url*: (proc(s: string): Result[string, JSError]) StartConfig = object visual_home*: string @@ -176,8 +176,7 @@ proc getSiteConfig*(config: Config, jsctx: JSContext): seq[SiteConfig] = if sc.rewrite_url.isSome: let fun = jsctx.eval(sc.rewrite_url.get, "<siteconf>", JS_EVAL_TYPE_GLOBAL) - let f = getJSFunction[URL, URL](jsctx, fun) - conf.rewrite_url = f.get + conf.rewrite_url = getJSFunction[URL, URL](jsctx, fun) result.add(conf) proc getOmniRules*(config: Config, jsctx: JSContext): seq[OmniRule] = @@ -187,8 +186,7 @@ proc getOmniRules*(config: Config, jsctx: JSContext): seq[OmniRule] = match: re.get ) let fun = jsctx.eval(rule.substitute_url, "<siteconf>", JS_EVAL_TYPE_GLOBAL) - let f = getJSFunction[string, string](jsctx, fun) - conf.substitute_url = f.get + conf.substitute_url = getJSFunction[string, string](jsctx, fun) result.add(conf) func getRealKey(key: string): string = |