🎨 自动添加http前缀到baseUrl以确保URL格式正确
This commit is contained in:
parent
ba4b5792f7
commit
578531cb13
@ -13,6 +13,7 @@ import (
|
||||
"gitee.ltd/lxh/xybot/user"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@ -43,6 +44,10 @@ func NewClient(wxId, baseUrl string, debug bool) (cli *Client, err error) {
|
||||
err = errors.New("baseUrl 不得为空,格式为: http://10.0.0.11:9001")
|
||||
return
|
||||
}
|
||||
// 如果URL没有以http://或https://开头,自动添加http://
|
||||
if !strings.HasPrefix(baseUrl, "http://") && !strings.HasPrefix(baseUrl, "https://") {
|
||||
baseUrl = "http://" + baseUrl
|
||||
}
|
||||
// 设置一下机器人微信Id的值
|
||||
core.WxId = wxId
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user