Skip to content

Commit 6e83595

Browse files
committed
Fix IP address regex
1 parent c448d9e commit 6e83595

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

api/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ var QueryRoute = MakeRouteSpec[QueryRequest, QueryResponse](
3131
)
3232

3333
var (
34-
ErrInvalidIPFormat = errors.New("Invalid IP Format. IPs must be in the format '%d.%d.%d.%d'.")
34+
ErrInvalidIPFormat = errors.New("Invalid IP Format. IPs must be in the format 'xx.xx.xx.xx'.")
3535
ErrInvalidDeviceID = errors.New("DeviceID cannot be 0.")
3636
ErrInvalidCsnum = errors.New("Csnums must be less than 16 characters long and match the format '^[a-zA-Z0-9]+$'.")
3737
ErrInvalidHasBan = errors.New("HasBan must be either 0 (Either), 1 (No Ban), 2 (Ban)")
3838
ErrEmptyParams = errors.New("At least one of IP, Csnum, and DeviceID must be nonzero or nonempty")
3939

40-
ipRegex = regexp.MustCompile(`\d\.\d\.\d\.`)
40+
ipRegex = regexp.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)
4141
csnumRegex = regexp.MustCompile(`^[a-zA-Z0-9]+$`)
4242
)
4343

0 commit comments

Comments
 (0)