Skip to content

Commit

Permalink
Merge pull request #1476 from vrothberg/full-id-regex
Browse files Browse the repository at this point in the history
docker/reference: add IsFullIdentifier
  • Loading branch information
vrothberg committed Feb 24, 2022
2 parents 306f204 + 40befe3 commit 1045fb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker/reference/regexp-additions.go
@@ -0,0 +1,6 @@
package reference

// Return true if the specified string fully matches `IdentifierRegexp`.
func IsFullIdentifier(s string) bool {
return anchoredIdentifierRegexp.MatchString(s)
}
3 changes: 3 additions & 0 deletions docker/reference/regexp_test.go
Expand Up @@ -545,6 +545,9 @@ func TestIdentifierRegexp(t *testing.T) {

for i := range fullCases {
checkRegexp(t, anchoredIdentifierRegexp, fullCases[i])
if IsFullIdentifier(fullCases[i].input) != fullCases[i].match {
t.Errorf("Expected match for %q to be %v", fullCases[i].input, fullCases[i].match)
}
}

for i := range shortCases {
Expand Down

0 comments on commit 1045fb7

Please sign in to comment.