File tree 2 files changed +27
-5
lines changed
2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -276,12 +276,18 @@ func parseConfigNodeLink(node *ConfigNode) *ConfigNode {
276
276
node .Pass = match [3 ]
277
277
node .Protocol = match [4 ]
278
278
array := gstr .Split (match [5 ], ":" )
279
- if len (array ) == 2 && node .Protocol != "file" {
280
- node .Host = array [0 ]
281
- node .Port = array [1 ]
282
- node .Name = match [6 ]
283
- } else {
279
+ if node .Protocol == "file" {
284
280
node .Name = match [5 ]
281
+ } else {
282
+ if len (array ) == 2 {
283
+ // link with port.
284
+ node .Host = array [0 ]
285
+ node .Port = array [1 ]
286
+ } else {
287
+ // link without port.
288
+ node .Host = array [0 ]
289
+ }
290
+ node .Name = match [6 ]
285
291
}
286
292
if len (match ) > 6 && match [7 ] != "" {
287
293
node .Extra = match [7 ]
Original file line number Diff line number Diff line change @@ -232,6 +232,22 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) {
232
232
t .Assert (newNode .Charset , defaultCharset )
233
233
t .Assert (newNode .Protocol , `tcp` )
234
234
})
235
+ // #3755
236
+ gtest .C (t , func (t * gtest.T ) {
237
+ node := & ConfigNode {
238
+ Link : "mysql:user:pwd@tcp(rdsid.mysql.rds.aliyuncs.com)/dbname?charset=utf8&loc=Local" ,
239
+ }
240
+ newNode := parseConfigNodeLink (node )
241
+ t .Assert (newNode .Type , `mysql` )
242
+ t .Assert (newNode .User , `user` )
243
+ t .Assert (newNode .Pass , `pwd` )
244
+ t .Assert (newNode .Host , `rdsid.mysql.rds.aliyuncs.com` )
245
+ t .Assert (newNode .Port , `` )
246
+ t .Assert (newNode .Name , `dbname` )
247
+ t .Assert (newNode .Extra , `charset=utf8&loc=Local` )
248
+ t .Assert (newNode .Charset , `utf8` )
249
+ t .Assert (newNode .Protocol , `tcp` )
250
+ })
235
251
}
236
252
237
253
func Test_Func_doQuoteWord (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments