fix(retainer): Handle zero-length topic levels
This commit is contained in:
parent
bc96c9fda7
commit
8ff9a03df3
|
@ -176,11 +176,11 @@ condition([NIndex | OtherIndex], ['+' | OtherTokens], N, IndexMatch, OtherMatch)
|
|||
condition(Index, ['+' | OtherTokens], N, IndexMatch, OtherMatch) ->
|
||||
condition(Index, OtherTokens, N + 1, IndexMatch, ['_' | OtherMatch]);
|
||||
condition([NIndex | OtherIndex], [Token | OtherTokens], N, IndexMatch, OtherMatch) when
|
||||
NIndex =:= N, is_binary(Token)
|
||||
NIndex =:= N, is_binary(Token) orelse Token =:= ''
|
||||
->
|
||||
condition(OtherIndex, OtherTokens, N + 1, [Token | IndexMatch], OtherMatch);
|
||||
condition(Index, [Token | OtherTokens], N, IndexMatch, OtherMatch) when
|
||||
is_binary(Token)
|
||||
is_binary(Token) orelse Token =:= ''
|
||||
->
|
||||
condition(Index, OtherTokens, N + 1, IndexMatch, [Token | OtherMatch]).
|
||||
|
||||
|
|
|
@ -193,6 +193,14 @@ t_condition_index(_Config) ->
|
|||
[1],
|
||||
[<<"a">>, '#']
|
||||
)
|
||||
),
|
||||
|
||||
?assertEqual(
|
||||
{[1, 2, 3], {['', <<"saya">>, '_'], []}},
|
||||
emqx_retainer_index:condition(
|
||||
[1, 2, 3],
|
||||
['', <<"saya">>, '+']
|
||||
)
|
||||
).
|
||||
|
||||
t_restore_topic(_Config) ->
|
||||
|
|
Loading…
Reference in New Issue