Fix user ID encoding for empty string

This commit is contained in:
Enes Cakir
2021-02-11 00:24:51 +03:00
parent 008788ad89
commit 6d901e4b11
+2 -3
View File
@@ -48,9 +48,8 @@ func EncodeID(id string) string {
// hashWithFallback tries to has val with hash.Hash and fallback to crc if needed
func hashWithFallback(h hash.Hash, val string) string {
if reValidSha.MatchString(val) {
return val // already hashed or empty
if len(val) == 0 || reValidSha.MatchString(val) {
return val // empty or already hashed
}
if _, err := io.WriteString(h, val); err != nil {