~amolith/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH go-webring] handlers: Fix off-by-one in previous endpoint

Details
Message ID
<20240614153114.938780-1-hi@taavi.wtf>
DKIM signature
pass
Download raw message
Patch: +1 -1
Fixes an off-by-one comparison in the previous endpoint that prevented
the second site in the order (list index #1) from ever redirecting to
the first (list index #0).

Signed-off-by: Taavi Väänänen <hi@taavi.wtf>
---
 handlers.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/handlers.go b/handlers.go
index 609525f..e219510 100644
--- a/handlers.go
+++ b/handlers.go
@@ -84,7 +84,7 @@ func (m model) previous(writer http.ResponseWriter, request *http.Request) {
	for index, item := range m.ring {
		if item.url == host {
			// from here to start of list
			for i := index - 1; i > 0; i-- {
			for i := index - 1; i >= 0; i-- {
				dest := scheme + m.ring[i].url
				if is200(dest) {
					log.Println("Redirecting visitor to '" + dest + "'")
-- 
2.43.0
Details
Message ID
<875xuba4wj.fsf@secluded.site>
In-Reply-To
<20240614153114.938780-1-hi@taavi.wtf> (view parent)
DKIM signature
pass
Download raw message
Applied and deployed, thanks! :)

https://lists.sr.ht/~amolith/public-inbox/%3C20240614153114.938780-1-hi@taavi.wtf%3E
Reply to thread Export thread (mbox)