Skip to content

Commit

Permalink
fix(hooencod): bug reported by Hoo self
Browse files Browse the repository at this point in the history
  • Loading branch information
hugefiver committed Feb 12, 2025
1 parent 87c0d21 commit bd9512f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
image: csusters/csust-got
tags: |
latest-${{ github.ref_name }}
${{ github.ref_name }}
${{ github.ref_name }}~
containerfiles: |
./Dockerfile
layers: true
Expand Down
2 changes: 1 addition & 1 deletion base/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))])
}
Expand Down
3 changes: 3 additions & 0 deletions base/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bd9512f

Please sign in to comment.