package yu_http

const toLower = 'a' - 'A'

// Normalize
//
//	@Description: 标准化协议头
func Normalize(key string) string {
	j_buf := make([]byte, 0, len(key))
	j_upper := true
	for j_i := 0; j_i < len(key); j_i++ {
		if j_upper && 'a' <= key[j_i] && key[j_i] <= 'z' {
			j_buf = append(j_buf, key[j_i]-toLower)
		} else if !j_upper && 'A' <= key[j_i] && key[j_i] <= 'Z' {
			j_buf = append(j_buf, key[j_i]+toLower)
		} else {
			j_buf = append(j_buf, key[j_i])
		}
		j_upper = key[j_i] == '-' // for next time
	}
	return string(j_buf)
}
