Use at least 2 characters

This commit is contained in:
Andreas Mieke 2018-06-09 18:26:21 +02:00
parent 840cd1b471
commit 09ce8b265c
No known key found for this signature in database
GPG key ID: 0C26F7695C85F85A

View file

@ -48,7 +48,7 @@ func Encode(c *gin.Context) {
hasher := sha512.New()
hasher.Write([]byte(URL.Long.String))
base := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
i := 1
i := 2
for {
database.Db.Model(&database.URL{}).Where("short = ?", base[0:i]).Count(&count)
if count > 0 && i < len(base) {