From 99a47e76449d81ca580e3eb76b25d0b910b4b75c Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Mon, 30 Nov 2020 19:27:59 +0800 Subject: [PATCH] fix reg_express --- server/web/tree.go | 3 +++ server/web/tree_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/web/tree.go b/server/web/tree.go index fc5a11a2..b389e148 100644 --- a/server/web/tree.go +++ b/server/web/tree.go @@ -570,6 +570,9 @@ func splitSegment(key string) (bool, []string, string) { param = make([]rune, 0) } else if v == '?' { params = append(params, ":") + } else if v == '.' { + out = append(out, '\\') + out = append(out, v) } else { out = append(out, v) } diff --git a/server/web/tree_test.go b/server/web/tree_test.go index b6b3d52a..92a6b7f2 100644 --- a/server/web/tree_test.go +++ b/server/web/tree_test.go @@ -323,8 +323,8 @@ func TestSplitSegment(t *testing.T) { ":name:string": {true, []string{":name"}, `([\w]+)`}, ":id([0-9]+)": {true, []string{":id"}, `([0-9]+)`}, ":id([0-9]+)_:name": {true, []string{":id", ":name"}, `([0-9]+)_(.+)`}, - ":id(.+)_cms.html": {true, []string{":id"}, `(.+)_cms.html`}, - "cms_:id(.+)_:page(.+).html": {true, []string{":id", ":page"}, `cms_(.+)_(.+).html`}, + ":id(.+)_cms.html": {true, []string{":id"}, `(.+)_cms\.html`}, + "cms_:id(.+)_:page(.+).html": {true, []string{":id", ":page"}, `cms_(.+)_(.+)\.html`}, `:app(a|b|c)`: {true, []string{":app"}, `(a|b|c)`}, `:app\((a|b|c)\)`: {true, []string{":app"}, `(.+)\((a|b|c)\)`}, }