// NormalizeTag returns a language tag with all lower-case characters
// and dashes "-" instead of underscores "_"
507723
func NormalizeTag(tag string) string {
	tag = strings.ToLower(tag)
	return strings.Replace(tag, "_", "-", -1)
}
120329
func (f *File) Normalize() error {
	for tempName, t := range f.Template {
		if err := t.Normalize(); err != nil {
			return fmt.Errorf("template %q: %s", tempName, err)
		}
	}
	return nil
}
598281
func (s *Stage) Normalize() error {
	switch st := s.GetStageType().(type) {
	case *Stage_Failure:
		return st.Failure.Normalize()
	case *Stage_Stall:
		return st.Stall.Normalize()
	case *Stage_Deps:
		return st.Deps.Normalize()
	}
	return fmt.Errorf("empty stage")
}
801791
func (arc *AddressResourceConfig) Normalize() {
	testProto := strings.Trim(strings.ToLower(arc.Protocol), " ")
	arc.Protocol = testProto
}
342552
func StripTags(raw string, strict, escaped bool) (string, error) {
	// Remove escaping.
	xmldoc := raw
	if escaped {
		xmldoc = html.UnescapeString(xmldoc)
	}
	// Decode the document.
	buffer := []string{}
	dec := xml.NewDecoder(bytes.NewBufferString(xmldoc))
	dec.Strict = strict
	dec.CharsetReader = CharsetReader
	for {
		token, err := dec.Token()
		if err == io.EOF {
			break
		}
		if err != nil {
			return "", err
		}
		switch t := token.(type) {
		case xml.CharData:
			trimmed := strings.TrimSpace(string(t))
			buffer = append(buffer, trimmed)
		default:
			// NOP.
		}
	}
	return strings.Join(buffer, " "), nil
}
473144
func (p *CipdPackage) Normalize() error {
	if p.Name == "" {
		return errors.New("missing name")
	}
	if p.Version == "" {
		return errors.New("missing version")
	}
	return nil
}
954736
func Add(l *Language) {
	tag := NormalizeTag(l.Tag)
	pluralSpecs[tag] = l.PluralSpec
}
1088722
func (h Host) Normalize() string {
	s := string(h)
	_, s = parse.Transport(s)

	// The error can be ignore here, because this function is called after the corefile has already been vetted.
	host, _, _, _ := SplitHostPort(s)
	return Name(host).Normalize()
}
975047
func normalizeSemString(str, alphabet string) string {
	var result bytes.Buffer
	for _, r := range str {
		if strings.ContainsRune(alphabet, r) {
			result.WriteRune(r)
		}
	}
	return result.String()
}
1313615
func (slice TagSlice) RegularTags() []*Tag {
	tags := make([]*Tag, 0)

	inAppDataRange := false
	for _, tag := range slice {
		if tag.Code >= 1000 {
			continue
		}

		if tag.Code == appDataMarker {
			if inAppDataRange {
				inAppDataRange = false
			} else {
				inAppDataRange = true
			}
			continue
		}

		if !inAppDataRange {
			tags = append(tags, tag)
		}
	}

	return tags
}
1195828
func validateTag(rawRepo string) error {
	_, err := reference.ParseNormalizedNamed(rawRepo)

	return err
}
509637
func (e Error) Tag(tag Error) Error {
	return Error(string(tag) + ":" + string(e))
}
516630
func NormalizeURL(u *url.URL, f NormalizationFlags) string {
	for _, k := range flagsOrder {
		if f&k == k {
			flags[k](u)
		}
	}
	return urlesc.Escape(u)
}
1359519
func MustNormalizeURLString(u string, f NormalizationFlags) string {
	result, e := NormalizeURLString(u, f)
	if e != nil {
		panic(e)
	}
	return result
}
288377
func Normalize(name string) string {
	fargs := func(c rune) bool {
		return !unicode.IsLetter(c) && !unicode.IsNumber(c)
	}
	// get function
	return strings.Join(strings.FieldsFunc(name, fargs), "-")
}
912432
func CheckTag(tag string) error {
	for _, v := range tag {
		if !u.IsLetter(v) && !unicode.IsDigit(v) && v != ' ' && v != '-' && v != '_' && v != '.' && v != '/' && v != ':' {
			return e.Push(e.New(ErrInvalidTagChar), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
1155424
func RemoveTag(image string) string {
	if !HasTag(image) {
		return image
	}
	tagRegex := regexp.MustCompile(tagRegexStr)
	parts := tagRegex.FindStringSubmatch(image)
	tag := parts[len(parts)-1]
	return image[0 : len(image)-len(tag)-1]
}