Skip to content

Commit a56df1e

Browse files
committed
frontend/dockerfile: parseExtraHosts(): use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent b2c617c commit a56df1e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

frontend/dockerfile/builder/build.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,10 @@ func parseExtraHosts(v string) ([]llb.HostIP, error) {
759759
return nil, err
760760
}
761761
for _, field := range fields {
762-
parts := strings.SplitN(field, "=", 2)
763-
if len(parts) != 2 {
762+
key, val, ok := strings.Cut(strings.ToLower(field), "=")
763+
if !ok {
764764
return nil, errors.Errorf("invalid key-value pair %s", field)
765765
}
766-
key := strings.ToLower(parts[0])
767-
val := strings.ToLower(parts[1])
768766
ip := net.ParseIP(val)
769767
if ip == nil {
770768
return nil, errors.Errorf("failed to parse IP %s", val)

0 commit comments

Comments
 (0)