Skip to content

Commit 1ff7288

Browse files
committed
added a (passing) test for empty pattern in ng.re.match.
1 parent d37c193 commit 1ff7288

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

t/034-match.t

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use Test::Nginx::Socket;
99

1010
repeat_each(2);
1111

12-
plan tests => repeat_each() * (blocks() * 2 + 4);
12+
plan tests => repeat_each() * (blocks() * 2 + 5);
1313

1414
#no_diff();
1515
no_long_string();
@@ -702,3 +702,27 @@ done
702702
--- response_body
703703
done
704704

705+
706+
707+
=== TEST 34: non-empty subject, empty pattern
708+
--- config
709+
location /re {
710+
content_by_lua '
711+
local ctx = {}
712+
local m = ngx.re.match("hello, 1234", "", "", ctx)
713+
if m then
714+
ngx.say("pos: ", ctx.pos)
715+
ngx.say("m: ", m[0])
716+
else
717+
ngx.say("not matched!")
718+
end
719+
';
720+
}
721+
--- request
722+
GET /re
723+
--- response_body
724+
pos: 0
725+
m:
726+
--- no_error_log
727+
[error]
728+

0 commit comments

Comments
 (0)