Use at least 2 characters
This commit is contained in:
parent
840cd1b471
commit
09ce8b265c
|
@ -48,7 +48,7 @@ func Encode(c *gin.Context) {
|
||||||
hasher := sha512.New()
|
hasher := sha512.New()
|
||||||
hasher.Write([]byte(URL.Long.String))
|
hasher.Write([]byte(URL.Long.String))
|
||||||
base := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
|
base := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
|
||||||
i := 1
|
i := 2
|
||||||
for {
|
for {
|
||||||
database.Db.Model(&database.URL{}).Where("short = ?", base[0:i]).Count(&count)
|
database.Db.Model(&database.URL{}).Where("short = ?", base[0:i]).Count(&count)
|
||||||
if count > 0 && i < len(base) {
|
if count > 0 && i < len(base) {
|
||||||
|
|
Loading…
Reference in a new issue