diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-13 02:03:47 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-13 02:03:47 +0100 |
commit | 89750ef4ad621fe7fdce533d1265f3d970098a19 (patch) | |
tree | 0aa80ceb07ce0ad49e5c3ba369f96bb67c1b6dd5 /src/display | |
parent | d9e430c8147c8c2d81b4ca5405786269b2cfc94d (diff) | |
download | chawan-89750ef4ad621fe7fdce533d1265f3d970098a19.tar.gz |
Update config and config docs
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/pager.nim | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/display/pager.nim b/src/display/pager.nim index 06b28346..66280edc 100644 --- a/src/display/pager.nim +++ b/src/display/pager.nim @@ -483,7 +483,9 @@ proc applySiteconf(pager: Pager, request: Request) = pager.cookiejars[request.url.host] = newCookieJar(request.url) # Load request in a new buffer. -proc gotoURL*(pager: Pager, request: Request, prevurl = none(URL), ctype = none(string), replace: Container = nil) = +proc gotoURL*(pager: Pager, request: Request, prevurl = none(URL), + ctype = none(string), replace: Container = nil, + redirectdepth = 0) = pager.applySiteconf(request) if prevurl.isnone or not prevurl.get.equals(request.url, true) or request.url.hash == "" or request.httpmethod != HTTP_GET: @@ -500,7 +502,7 @@ proc gotoURL*(pager: Pager, request: Request, prevurl = none(URL), ctype = none( location: request.url ) let cookiejar = pager.cookiejars.getOrDefault(request.url.host) - let container = pager.dispatcher.newBuffer(pager.config, source, cookiejar) + let container = pager.dispatcher.newBuffer(pager.config, source, cookiejar, redirectdepth = redirectdepth) if replace != nil: container.replace = replace container.copyCursorPos(container.replace) @@ -711,9 +713,12 @@ proc handleEvent0(pager: Pager, container: Container, event: ContainerEvent): bo if pager.container == container: pager.authorize() of REDIRECT: - let redirect = event.location - pager.alert("Redirecting to " & $redirect) - pager.gotoURL(newRequest(redirect), some(pager.container.source.location), replace = pager.container) + if container.redirectdepth < 10: + let redirect = event.location + pager.alert("Redirecting to " & $redirect) + pager.gotoURL(newRequest(redirect), some(container.source.location), replace = container, redirectdepth = container.redirectdepth + 1) + else: + pager.alert("Error: maximum redirection depth reached") of ANCHOR: var url2 = newURL(container.source.location) url2.hash(event.anchor) |