username regex now catches all exisiting twitch usernames and is no longer case sensitive

This commit is contained in:
gempir 2020-03-11 18:53:14 +01:00
parent c466651779
commit 1953254934
2 changed files with 7 additions and 6 deletions

View file

@ -36,7 +36,7 @@ type logTime struct {
}
var (
pathRegex = regexp.MustCompile(`\/(channel|channelid)\/([a-zA-Z0-9]+)(?:\/(user|userid)\/([a-zA-Z0-9]+))?(?:(?:\/(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?)|(?:\/(range|random)))?`)
pathRegex = regexp.MustCompile(`\/(channel|channelid)\/(\w+)(?:\/(user|userid)\/(\w+))?(?:(?:\/(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?)|(?:\/(range|random)))?`)
)
func (s *Server) newLogRequestFromURL(r *http.Request) (logRequest, error) {
@ -153,10 +153,10 @@ func (s *Server) fillIds(request logRequest) (logRequest, error) {
}
if request.channelid == "" {
request.channelid = ids[request.channel].ID
request.channelid = ids[strings.ToLower(request.channel)].ID
}
if request.userid == "" {
request.userid = ids[request.user].ID
request.userid = ids[strings.ToLower(request.user)].ID
}
return request, nil

View file

@ -2,6 +2,7 @@ package helix
import (
"net/http"
"strings"
helixClient "github.com/nicklaw5/helix"
log "github.com/sirupsen/logrus"
@ -110,8 +111,8 @@ func (c *Client) GetUsersByUsernames(usernames []string) (map[string]UserData, e
var filteredUsernames []string
for _, username := range usernames {
if _, ok := userCacheByUsername[username]; !ok {
filteredUsernames = append(filteredUsernames, username)
if _, ok := userCacheByUsername[strings.ToLower(username)]; !ok {
filteredUsernames = append(filteredUsernames, strings.ToLower(username))
}
}
@ -146,7 +147,7 @@ func (c *Client) GetUsersByUsernames(usernames []string) (map[string]UserData, e
result := make(map[string]UserData)
for _, username := range usernames {
result[username] = *userCacheByUsername[username]
result[strings.ToLower(username)] = *userCacheByUsername[strings.ToLower(username)]
}
return result, nil