mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-28 11:14:54 -04:00
forgery: safer unique name
This commit is contained in:
parent
d25f7ae70d
commit
a8fac9b1e2
1 changed files with 2 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"math/rand/v2"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
org_model "forgejo.org/models/organization"
|
||||
|
|
@ -19,7 +20,7 @@ var nameCleaner = regexp.MustCompile(`[^a-zA-Z0-9-]+`) // exclude "_", to preven
|
|||
|
||||
// uniqueSafeName replaces specials chars with _ and appends a random hex suffix
|
||||
func uniqueSafeName(testName string) string {
|
||||
return nameCleaner.ReplaceAllLiteralString(testName, "_") + "-" + strconv.FormatUint(uint64(rand.Uint32()), 16)
|
||||
return strings.Trim(nameCleaner.ReplaceAllLiteralString(testName, "_"), "-_") + "-" + strconv.FormatUint(uint64(rand.Uint32()), 16)
|
||||
}
|
||||
|
||||
type CreateUserOptions struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue