mirror of
https://github.com/distribution/reference.git
synced 2026-10-28 10:15:29 +08:00
make more expressions a const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
2 files changed
+7
-4
No files matched your search
@@ -89,14 +89,12 @@ const (
|
||||
// are allowed, IPv6 zone identifiers (rfc6874) or Special addresses such as
|
||||
// IPv4-Mapped are deliberately excluded.
|
||||
ipv6address = `\[(?:[a-fA-F0-9:]+)\]`
|
||||
)
|
||||
|
||||
var (
|
||||
// domainName defines the structure of potential domain components
|
||||
// that may be part of image names. This is purposely a subset of what is
|
||||
// allowed by DNS to ensure backwards compatibility with Docker image
|
||||
// names. This includes IPv4 addresses on decimal format.
|
||||
domainName = domainNameComponent + anyTimes(`\.`+domainNameComponent)
|
||||
domainName = domainNameComponent + `(?:\.` + domainNameComponent + `)*`
|
||||
|
||||
// host defines the structure of potential domains based on the URI
|
||||
// Host subcomponent on rfc3986. It may be a subset of DNS domain name,
|
||||
@@ -108,7 +106,9 @@ var (
|
||||
// allowed by the URI Host subcomponent on rfc3986 to ensure backwards
|
||||
// compatibility with Docker image names.
|
||||
domainAndPort = host + optionalPort
|
||||
)
|
||||
|
||||
var (
|
||||
// anchoredTagRegexp matches valid tag names, anchored at the start and
|
||||
// end of the matched string.
|
||||
anchoredTagRegexp = regexp.MustCompile(anchored(tag))
|
||||
|
||||
+4
-1
@@ -161,7 +161,10 @@ func TestDomainRegexp(t *testing.T) {
|
||||
match: false,
|
||||
},
|
||||
}
|
||||
r := regexp.MustCompile(`^` + DomainRegexp.String() + `$`)
|
||||
r, err := regexp.Compile(`^` + domainAndPort + `$`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.input, func(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user