Makes UUID regex case-insensitive.
This commit is contained in:
parent
a1e02996e5
commit
f4943c1613
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
// validUUID is used to check if a given string looks like a UUID
|
||||
var validUUID = regexp.MustCompile(`^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$`)
|
||||
var validUUID = regexp.MustCompile(`(?i)^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$`)
|
||||
|
||||
// isUUID returns true if the given string is a valid UUID.
|
||||
func isUUID(str string) bool {
|
||||
|
|
|
@ -13,9 +13,14 @@ func TestStateStore_PreparedQuery_isUUID(t *testing.T) {
|
|||
"": false,
|
||||
"nope": false,
|
||||
"f004177f-2c28-83b7-4229-eacc25fe55d1": true,
|
||||
"F004177F-2C28-83B7-4229-EACC25FE55D1": true,
|
||||
"x004177f-2c28-83b7-4229-eacc25fe55d1": false, // Bad hex
|
||||
"f004177f-xc28-83b7-4229-eacc25fe55d1": false, // Bad hex
|
||||
"f004177f-2c28-x3b7-4229-eacc25fe55d1": false, // Bad hex
|
||||
"f004177f-2c28-83b7-x229-eacc25fe55d1": false, // Bad hex
|
||||
"f004177f-2c28-83b7-4229-xacc25fe55d1": false, // Bad hex
|
||||
" f004177f-2c28-83b7-4229-eacc25fe55d1": false, // Leading whitespace
|
||||
"f004177f-2c28-83b7-4229-eacc25fe55d1 ": false, // Trailing whitespace
|
||||
"f004177f-2c28-83B7-4229-eacc25fe55d1": false, // Bad hex "83B7"
|
||||
}
|
||||
for i := 0; i < 100; i++ {
|
||||
cases[testUUID()] = true
|
||||
|
|
Loading…
Reference in a new issue