Merge pull request #7631 from thaJeztah/strings_cut

replace strings.Split(N) for strings.Cut() or alternatives
This commit is contained in:
Kazuyoshi Kato
2022-11-10 15:28:22 -08:00
committed by GitHub
20 changed files with 116 additions and 111 deletions

View File

@@ -233,11 +233,10 @@ func ParseAuth(auth *runtime.AuthConfig, host string) (string, string, error) {
if err != nil {
return "", "", err
}
fields := strings.SplitN(string(decoded), ":", 2)
if len(fields) != 2 {
user, passwd, ok := strings.Cut(string(decoded), ":")
if !ok {
return "", "", fmt.Errorf("invalid decoded auth: %q", decoded)
}
user, passwd := fields[0], fields[1]
return user, strings.Trim(passwd, "\x00"), nil
}
// TODO(random-liu): Support RegistryToken.