mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 19:57:40 +08:00
This commit is contained in:
parent
4ee5bf5c45
commit
6a99931798
@ -276,12 +276,18 @@ func parseConfigNodeLink(node *ConfigNode) *ConfigNode {
|
|||||||
node.Pass = match[3]
|
node.Pass = match[3]
|
||||||
node.Protocol = match[4]
|
node.Protocol = match[4]
|
||||||
array := gstr.Split(match[5], ":")
|
array := gstr.Split(match[5], ":")
|
||||||
if len(array) == 2 && node.Protocol != "file" {
|
if node.Protocol == "file" {
|
||||||
node.Host = array[0]
|
|
||||||
node.Port = array[1]
|
|
||||||
node.Name = match[6]
|
|
||||||
} else {
|
|
||||||
node.Name = match[5]
|
node.Name = match[5]
|
||||||
|
} else {
|
||||||
|
if len(array) == 2 {
|
||||||
|
// link with port.
|
||||||
|
node.Host = array[0]
|
||||||
|
node.Port = array[1]
|
||||||
|
} else {
|
||||||
|
// link without port.
|
||||||
|
node.Host = array[0]
|
||||||
|
}
|
||||||
|
node.Name = match[6]
|
||||||
}
|
}
|
||||||
if len(match) > 6 && match[7] != "" {
|
if len(match) > 6 && match[7] != "" {
|
||||||
node.Extra = match[7]
|
node.Extra = match[7]
|
||||||
|
@ -232,6 +232,22 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) {
|
|||||||
t.Assert(newNode.Charset, defaultCharset)
|
t.Assert(newNode.Charset, defaultCharset)
|
||||||
t.Assert(newNode.Protocol, `tcp`)
|
t.Assert(newNode.Protocol, `tcp`)
|
||||||
})
|
})
|
||||||
|
// #3755
|
||||||
|
gtest.C(t, func(t *gtest.T) {
|
||||||
|
node := &ConfigNode{
|
||||||
|
Link: "mysql:user:pwd@tcp(rdsid.mysql.rds.aliyuncs.com)/dbname?charset=utf8&loc=Local",
|
||||||
|
}
|
||||||
|
newNode := parseConfigNodeLink(node)
|
||||||
|
t.Assert(newNode.Type, `mysql`)
|
||||||
|
t.Assert(newNode.User, `user`)
|
||||||
|
t.Assert(newNode.Pass, `pwd`)
|
||||||
|
t.Assert(newNode.Host, `rdsid.mysql.rds.aliyuncs.com`)
|
||||||
|
t.Assert(newNode.Port, ``)
|
||||||
|
t.Assert(newNode.Name, `dbname`)
|
||||||
|
t.Assert(newNode.Extra, `charset=utf8&loc=Local`)
|
||||||
|
t.Assert(newNode.Charset, `utf8`)
|
||||||
|
t.Assert(newNode.Protocol, `tcp`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Func_doQuoteWord(t *testing.T) {
|
func Test_Func_doQuoteWord(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user