20 lines
467 B
Go
20 lines
467 B
Go
package domain
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
// NormalizeSessionID applies the shared session identifier rule.
|
|
func NormalizeSessionID(raw string) (string, error) {
|
|
normalized := strings.TrimSpace(raw)
|
|
if normalized == "" {
|
|
return "", nil
|
|
}
|
|
if length := utf8.RuneCountInString(normalized); length > SessionIDMaxLength {
|
|
return "", fmt.Errorf("session_id length %d exceeds maximum %d", length, SessionIDMaxLength)
|
|
}
|
|
return normalized, nil
|
|
}
|