This commit is contained in:
2022-03-19 18:49:41 -07:00
parent 94f996c10d
commit 618ccc23b9
8 changed files with 449 additions and 10 deletions

View File

@@ -2,7 +2,9 @@ package links
import (
"crypto/rand"
"fmt"
"math/big"
"regexp"
)
const codeLength = 5
@@ -10,6 +12,7 @@ const codeLength = 5
var (
alphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789"
alphabetLength = big.NewInt(int64(len(alphabet)))
ValidShortCode = regexp.MustCompile(fmt.Sprintf(`^/[%s]{%d}$`, alphabet, codeLength))
)
func randInt() int {