commit 64b08e1e5fe43e66f9ec1e54408492907975b724
parent 5740e5eef190ea7e2a372f6c5da31c40910fe507
Author: Oliver Lowe <o@olowe.co>
Date: Sun, 6 Apr 2025 10:48:58 +1000
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.
Diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/internal/sip/sip.go b/internal/sip/sip.go
@@ -259,15 +259,22 @@ func parseStartLine(text string) (line [3]string, err error) {
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