reference: add const for (optional) port, and rename "domain" variable
The `domain` variable didn't make it clear that this could include port-numbers as well, so renaming it makes that more visible. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>master
							parent
							
								
									f0c7c97e73
								
							
						
					
					
						commit
						919bd8ab09
					
				|  | @ -23,6 +23,10 @@ const ( | ||||||
| 	// repository name to start with a component as defined by DomainRegexp.
 | 	// repository name to start with a component as defined by DomainRegexp.
 | ||||||
| 	domainNameComponent = `(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])` | 	domainNameComponent = `(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])` | ||||||
| 
 | 
 | ||||||
|  | 	// optionalPort matches an optional port-number including the port separator
 | ||||||
|  | 	// (e.g. ":80").
 | ||||||
|  | 	optionalPort = `(?::[0-9]+)?` | ||||||
|  | 
 | ||||||
| 	// tag matches valid tag names. From docker/docker:graph/tags.go.
 | 	// tag matches valid tag names. From docker/docker:graph/tags.go.
 | ||||||
| 	tag = `[\w][\w.-]{0,127}` | 	tag = `[\w][\w.-]{0,127}` | ||||||
| 
 | 
 | ||||||
|  | @ -66,7 +70,7 @@ var ( | ||||||
| 
 | 
 | ||||||
| 	// allowed by the URI Host subcomponent on rfc3986 to ensure backwards
 | 	// allowed by the URI Host subcomponent on rfc3986 to ensure backwards
 | ||||||
| 	// compatibility with Docker image names.
 | 	// compatibility with Docker image names.
 | ||||||
| 	domain = host + optional(`:[0-9]+`) | 	domainAndPort = host + optionalPort | ||||||
| 
 | 
 | ||||||
| 	// DomainRegexp matches hostname or IP-addresses, optionally including a port
 | 	// DomainRegexp matches hostname or IP-addresses, optionally including a port
 | ||||||
| 	// number. It defines the structure of potential domain components that may be
 | 	// number. It defines the structure of potential domain components that may be
 | ||||||
|  | @ -77,7 +81,7 @@ var ( | ||||||
| 	// addresses such as IPv4-Mapped).
 | 	// addresses such as IPv4-Mapped).
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// [rfc6874]: https://www.rfc-editor.org/rfc/rfc6874.
 | 	// [rfc6874]: https://www.rfc-editor.org/rfc/rfc6874.
 | ||||||
| 	DomainRegexp = regexp.MustCompile(domain) | 	DomainRegexp = regexp.MustCompile(domainAndPort) | ||||||
| 
 | 
 | ||||||
| 	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
 | 	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
 | ||||||
| 	TagRegexp = regexp.MustCompile(tag) | 	TagRegexp = regexp.MustCompile(tag) | ||||||
|  | @ -97,7 +101,7 @@ var ( | ||||||
| 	// character, with following parts able to be separated by a separator
 | 	// character, with following parts able to be separated by a separator
 | ||||||
| 	// (one period, one or two underscore and multiple dashes).
 | 	// (one period, one or two underscore and multiple dashes).
 | ||||||
| 	pathComponent = alphanumeric + optional(repeated(separator, alphanumeric)) | 	pathComponent = alphanumeric + optional(repeated(separator, alphanumeric)) | ||||||
| 	namePat       = optional(domain+`/`) + pathComponent + optional(repeated(`/`+pathComponent)) | 	namePat       = optional(domainAndPort+`/`) + pathComponent + optional(repeated(`/`+pathComponent)) | ||||||
| 
 | 
 | ||||||
| 	// NameRegexp is the format for the name component of references, including
 | 	// NameRegexp is the format for the name component of references, including
 | ||||||
| 	// an optional domain and port, but without tag or digest suffix.
 | 	// an optional domain and port, but without tag or digest suffix.
 | ||||||
|  | @ -105,7 +109,7 @@ var ( | ||||||
| 
 | 
 | ||||||
| 	// anchoredNameRegexp is used to parse a name value, capturing the
 | 	// anchoredNameRegexp is used to parse a name value, capturing the
 | ||||||
| 	// domain and trailing components.
 | 	// domain and trailing components.
 | ||||||
| 	anchoredNameRegexp = regexp.MustCompile(anchored(optional(capture(domain), `/`), capture(pathComponent, optional(repeated(`/`+pathComponent))))) | 	anchoredNameRegexp = regexp.MustCompile(anchored(optional(capture(domainAndPort), `/`), capture(pathComponent, optional(repeated(`/`+pathComponent))))) | ||||||
| 
 | 
 | ||||||
| 	referencePat = anchored(capture(namePat), optional(`:`, capture(tag)), optional(`@`, capture(digestPat))) | 	referencePat = anchored(capture(namePat), optional(`:`, capture(tag)), optional(`@`, capture(digestPat))) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue