From bd9512fa0fc8558dd5dc5b85422a23f238c5eb99 Mon Sep 17 00:00:00 2001 From: Hugefiver Date: Wed, 12 Feb 2025 16:07:14 +0800 Subject: [PATCH] fix(hooencod): bug reported by Hoo self --- .github/workflows/push.yml | 2 +- base/encode.go | 2 +- base/encode_test.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 55caf505..7a99ff6c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -32,7 +32,7 @@ jobs: image: csusters/csust-got tags: | latest-${{ github.ref_name }} - ${{ github.ref_name }} + ${{ github.ref_name }}~ containerfiles: | ./Dockerfile layers: true diff --git a/base/encode.go b/base/encode.go index d765e2f7..41d56f85 100644 --- a/base/encode.go +++ b/base/encode.go @@ -40,7 +40,7 @@ func hooEncode(s string) string { bs := bytes.NewBufferString("h") - if i1 >= i2-1 { + if i1 >= i2 { for range 4 { bs.WriteRune(hooRunes[rand.N(len(hooRunes))]) } diff --git a/base/encode_test.go b/base/encode_test.go index 595023f1..d87bb522 100644 --- a/base/encode_test.go +++ b/base/encode_test.go @@ -21,6 +21,9 @@ func Test_encode(t *testing.T) { {"h0o0o0OFAKER", "h0oFAKEROo"}, {"FAKERo0oO0", "h0oFAKEROo"}, {"h0o0o0OFAKERo0oO0", "h0oFAKEROo"}, + + // case from Hoo self + {"h0oaOo", "h0oaOo"}, } replacer := strings.NewReplacer(lo.FlatMap[string, string]([]string{"0", "o", "O"}, func(item string, _ int) []string { return []string{item, "o"} })...) for _, tt := range tests {