Skip to content

Commit 6255928

Browse files
dongbeioubamembphis
authored andcommitted
bugfix: should set data of the iterator. (#29)
* bugfix: should set data of the iterator. * add test case, multiple path with overlap
1 parent e6f95e0 commit 6255928

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/rax.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,7 @@ int raxSeek(raxIterator *it, const char *op, unsigned char *ele, size_t len) {
16731673
* node, but will be our match, representing the key "f".
16741674
*
16751675
* So in that case, we don't seek backward. */
1676+
it->data = raxGetData(it->node);
16761677
} else {
16771678
if (gt && !raxIteratorNextStep(it,0)) return 0;
16781679
if (lt && !raxIteratorPrevStep(it,0)) return 0;

t/path.t

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,36 @@ metadata multipe path 1
6767
metadata multipe path 2
6868
nil
6969
nil
70+
71+
72+
=== TEST 3: multiple path with overlap
73+
--- config
74+
location /t {
75+
content_by_lua_block {
76+
local radix = require("resty.radixtree")
77+
local rx = radix.new({
78+
{
79+
paths = {"/equal*"},
80+
metadata = "metadata multipe path 1",
81+
},
82+
{
83+
paths = {"/equal123*"},
84+
metadata = "metadata multipe path 2",
85+
},
86+
})
87+
88+
ngx.say(rx:match("/equal1"))
89+
ngx.say(rx:match("/equal12"))
90+
ngx.say(rx:match("/equal123"))
91+
ngx.say(rx:match("/equal1234"))
92+
}
93+
}
94+
--- request
95+
GET /t
96+
--- no_error_log
97+
[error]
98+
--- response_body
99+
metadata multipe path 1
100+
metadata multipe path 1
101+
metadata multipe path 2
102+
metadata multipe path 2

0 commit comments

Comments
 (0)