fix: incorrect checking of strings.Split return value

strings.Split will never return a slice of length 0 if sep is not empty, so any code that checks if the return value is of length 0 is incorrect and useless.
This commit is contained in:
wwqgtxx
2025-06-25 16:17:19 +08:00
parent 166392fe17
commit 5b975275f5
5 changed files with 27 additions and 15 deletions

View File

@@ -2,8 +2,9 @@ package common
import (
"fmt"
C "github.com/metacubex/mihomo/constant"
"strings"
C "github.com/metacubex/mihomo/constant"
)
type InUser struct {
@@ -36,8 +37,12 @@ func (u *InUser) Payload() string {
func NewInUser(iUsers, adapter string) (*InUser, error) {
users := strings.Split(iUsers, "/")
if len(users) == 0 {
return nil, fmt.Errorf("in user couldn't be empty")
for i, user := range users {
user = strings.TrimSpace(user)
if len(user) == 0 {
return nil, fmt.Errorf("in user couldn't be empty")
}
users[i] = user
}
return &InUser{