From f71b1a43a92c10b5d2313ccebac3d10cf8f911e5 Mon Sep 17 00:00:00 2001 From: Daniel Rocha Date: Sun, 17 Mar 2019 11:00:53 +0100 Subject: [PATCH] Change mod() function --- htp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htp.go b/htp.go index a6cfb9a..f5a0c39 100644 --- a/htp.go +++ b/htp.go @@ -112,7 +112,11 @@ func max(a, b int64) int64 { } func mod(x, m int64) int64 { - return (m + x%m) % m + y := x % m + if y >= 0 { + return y + } + return m + y } func noRedirect(req *http.Request, via []*http.Request) error {