~amolith/public-inbox

go-webring: handlers: Fix off-by-one in previous endpoint v1 APPLIED

Taavi Väänänen: 1
 handlers: Fix off-by-one in previous endpoint

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~amolith/public-inbox/patches/53297/mbox | git am -3
Learn more about email & git

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

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
Applied and deployed, thanks! :)

https://lists.sr.ht/~amolith/public-inbox/%3C20240614153114.938780-1-hi@taavi.wtf%3E