mirror of
https://gitee.com/johng/gf
synced 2026-07-07 14:25:17 +08:00
@ -15,6 +15,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gmeta"
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
@ -456,3 +457,22 @@ func Test_Issue2105(t *testing.T) {
|
||||
t.Assert(len(list[1].Json), 3)
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/gogf/gf/issues/2231
|
||||
func Test_Issue2231(t *testing.T) {
|
||||
linkPattern := `(\w+):([\w\-]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)`
|
||||
link := `mysql:root:12345678@tcp(127.0.0.1:3306)/a正bc式?loc=Local&parseTime=true`
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
|
||||
match, err := gregex.MatchString(linkPattern, link)
|
||||
t.AssertNil(err)
|
||||
t.Assert(match[1], "mysql")
|
||||
t.Assert(match[2], "root")
|
||||
t.Assert(match[3], "12345678")
|
||||
t.Assert(match[4], "tcp")
|
||||
t.Assert(match[5], "127.0.0.1:3306")
|
||||
t.Assert(match[6], "a正bc式")
|
||||
t.Assert(match[7], "loc=Local&parseTime=true")
|
||||
})
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ const (
|
||||
ctxKeyInternalProducedSQL gctx.StrKey = `CtxKeyInternalProducedSQL`
|
||||
|
||||
// type:[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
|
||||
linkPattern = `(\w+):([\w\-]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([\w\-]*)\?{0,1}(.*)`
|
||||
linkPattern = `(\w+):([\w\-]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)`
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user