mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-08 23:18:35 +00:00
Make repo whitelist case insensitive.
This is okay to do because it's a better user experience and because GitLab and GitHub project names are case insensitive as well.
This commit is contained in:
@@ -42,6 +42,10 @@ func (r *RepoWhitelist) IsWhitelisted(repoFullName string, vcsHostname string) b
|
||||
}
|
||||
|
||||
func (r *RepoWhitelist) matchesRule(rule string, candidate string) bool {
|
||||
// Case insensitive compare.
|
||||
rule = strings.ToLower(rule)
|
||||
candidate = strings.ToLower(candidate)
|
||||
|
||||
wildcardIdx := strings.Index(rule, Wildcard)
|
||||
if wildcardIdx == -1 {
|
||||
// No wildcard so can do a straight up match.
|
||||
|
||||
@@ -133,6 +133,20 @@ func TestIsWhitelisted(t *testing.T) {
|
||||
"github.com",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"should be case insensitive",
|
||||
"github.com/owner/repo",
|
||||
"OwNeR/rEpO",
|
||||
"github.com",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"should be case insensitive for wildcards",
|
||||
"github.com/owner/*",
|
||||
"OwNeR/rEpO",
|
||||
"github.com",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
||||
Reference in New Issue
Block a user