Skip to content

Commit f74be76

Browse files
authored
hotfix(wildpath): set user empty value (#47)
* hotfix(wildpath): set user empty value * fix(tree): modify tree ut
1 parent 0f5bbd6 commit f74be76

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

radix/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ walk:
315315
return child.handler, false
316316
case child.wildcard != nil:
317317
if ctx != nil {
318-
ctx.SetUserValue(child.wildcard.paramKey, copyString(path))
318+
ctx.SetUserValue(child.wildcard.paramKey, "")
319319
}
320320

321321
return child.wildcard.handler, false

radix/node_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestTreeWildcard(t *testing.T) {
173173
{"/cmd/test/", false, "/cmd/{tool}/", map[string]interface{}{"tool": "test"}},
174174
{"/cmd/test", true, "", nil},
175175
{"/cmd/test/3", false, "/cmd/{tool}/{sub}", map[string]interface{}{"tool": "test", "sub": "3"}},
176-
{"/src/", false, "/src/{filepath:*}", map[string]interface{}{"filepath": "/"}},
176+
{"/src/", false, "/src/{filepath:*}", map[string]interface{}{"filepath": ""}},
177177
{"/src/some/file.png", false, "/src/{filepath:*}", map[string]interface{}{"filepath": "some/file.png"}},
178178
{"/search/", false, "/search/", nil},
179179
{"/search/someth!ng+in+ünìcodé", false, "/search/{query}", map[string]interface{}{"query": "someth!ng+in+ünìcodé"}},

radix/tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (t *Tree) Get(path string, ctx *fasthttp.RequestCtx) (fasthttp.RequestHandl
8686
return t.root.handler, false
8787
case t.root.wildcard != nil:
8888
if ctx != nil {
89-
ctx.SetUserValue(t.root.wildcard.paramKey, "/")
89+
ctx.SetUserValue(t.root.wildcard.paramKey, "")
9090
}
9191

9292
return t.root.wildcard.handler, false

radix/tree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func Test_TreeRootWildcard(t *testing.T) {
238238
tree.Add("/{filepath:*}", handler)
239239

240240
testHandlerAndParams(t, tree, "/", handler, false, map[string]interface{}{
241-
"filepath": "/",
241+
"filepath": "",
242242
})
243243
}
244244

0 commit comments

Comments
 (0)