mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-06 14:17:32 +00:00
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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user