code: func Parse(s string) (Reference, error) {
  	matches := ReferenceRegexp.FindStringSubmatch(s)
  	if matches == nil {
  		if s == "" {
  			return nil, ErrNameEmpty
  		}
  		if ReferenceRegexp.FindStringSubmatch(strings.ToLower(s)) != nil {
  			return nil, ErrNameContainsUppercase
  		}
  		return nil, ErrReferenceInvalidFormat
  	}
  
  	if len(matches[1]) > NameTotalLengthMax {
  		return nil, ErrNameTooLong
  	}
  
  	var repo repository
  
  	nameMatch := anchoredNameRegexp.FindStringSubmatch(matches[1])
  	if len(nameMatch) == 3 {
  		repo.domain = nameMatch[1]
  		repo.path = nameMatch[2]
  	} else {
  		repo.domain = ""
  		repo.path = matches[1]
  	}
  
  	ref := reference{
  		namedRepository: repo,
  		tag:             matches[2],
  	}
  	if matches[3] != "" {
  		var err error
  		ref.digest, err = digest.Parse(matches[3])
  		if err != nil {
  			return nil, err
  		}
  	}
  
  	r := getBestReferenceType(ref)
  	if r == nil {
  		return nil, ErrNameEmpty
  	}
  
  	return r, nil
  }
docs: // Parse parses s and returns a syntactically valid Reference.
  // If an error was encountered it is returned, along with a nil Reference.
  // NOTE: Parse will not handle short digests.