commit 64b08e1e5fe43e66f9ec1e54408492907975b724 from: Oliver Lowe date: Sun Apr 6 00:48:58 2025 UTC internal/sip: extract containsSpace function We'll need it later and we're a few nested for loops and if stmts down so a little cleaner once we do this a few more times. commit - 5740e5eef190ea7e2a372f6c5da31c40910fe507 commit + 64b08e1e5fe43e66f9ec1e54408492907975b724 blob - ef73037cc9d6f7a5afef4090b30f7e5fb2bc9e5b blob + 2c65b272dda9d6e1bc870a40e60b4740d887f46b --- internal/sip/sip.go +++ internal/sip/sip.go @@ -259,15 +259,22 @@ func parseStartLine(text string) (line [3]string, err return line, fmt.Errorf("expected 3 fields, read %d", len(fields)) } for i, s := range fields { - for _, r := range s { - if unicode.IsSpace(r) { - return line, fmt.Errorf("illegal space character in field %d", i) - } + if containsSpace(s) { + return line, fmt.Errorf("illegal space character in field %d", i) } } return [3]string{fields[0], fields[1], fields[2]}, nil } +func containsSpace(s string) bool { + for _, r := range s { + if unicode.IsSpace(r) { + return true + } + } + return false +} + type CommandSequence struct { Number int Method string