diff --git a/.example/net/ghttp/server/router/duplicated/duplicated.go b/.example/net/ghttp/server/router/duplicated/duplicated.go new file mode 100644 index 00000000000..9402a2a4d2e --- /dev/null +++ b/.example/net/ghttp/server/router/duplicated/duplicated.go @@ -0,0 +1,20 @@ +package main + +import ( + "github.com/gogf/gf/frame/g" + "github.com/gogf/gf/net/ghttp" +) + +func main() { + s := g.Server() + s.Group("/", func(group *ghttp.RouterGroup) { + group.ALL("/test", func(r *ghttp.Request) { + r.Response.Writeln(1) + }) + group.ALL("/test", func(r *ghttp.Request) { + r.Response.Writeln(2) + }) + }) + s.SetPort(8199) + s.Run() +} diff --git a/os/gtime/gtime_format.go b/os/gtime/gtime_format.go index e1681cc6072..9b87c12b559 100644 --- a/os/gtime/gtime_format.go +++ b/os/gtime/gtime_format.go @@ -259,6 +259,7 @@ func formatToRegexPattern(format string) string { s := gregex.Quote(formatToStdLayout(format)) s, _ = gregex.ReplaceString(`[0-9]`, `[0-9]`, s) s, _ = gregex.ReplaceString(`[A-Za-z]`, `[A-Za-z]`, s) + s, _ = gregex.ReplaceString(`\s+`, `\s+`, s) return s } diff --git a/os/gtime/gtime_z_unit_basic_test.go b/os/gtime/gtime_z_unit_basic_test.go index c4e8b2c26d3..34ef936425c 100644 --- a/os/gtime/gtime_z_unit_basic_test.go +++ b/os/gtime/gtime_z_unit_basic_test.go @@ -275,6 +275,11 @@ func Test_ParseTimeFromContent(t *testing.T) { t.Error("test fail") } }) + + gtest.C(t, func(t *gtest.T) { + timeStr := "2021-1-27 9:10:24" + t.Assert(gtime.ParseTimeFromContent(timeStr, "Y-n-d g:i:s").String(), "2021-01-27 09:10:24") + }) } func Test_FuncCost(t *testing.T) {