Skip to content

Commit

Permalink
✨ Coerce Set search args into sequence-set
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Nov 8, 2024
1 parent d35835c commit 2db20a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,7 @@ def uid_expunge(uid_set)
# * When +criteria+ is an array, each member is a +SEARCH+ command argument:
# * Any SequenceSet sends SequenceSet#valid_string.
# These types are converted to SequenceSet for validation and encoding:
# * +Set+
# * +Range+
# * <tt>-1</tt> translates to <tt>*</tt>
# * nested +Array+
Expand Down Expand Up @@ -3204,7 +3205,7 @@ def normalize_searching_criteria(criteria)

def coerce_search_arg_to_seqset?(obj)
case obj
when -1 then true
when Set, -1 then true
when Range then true
when Array then true
else false
Expand Down
3 changes: 3 additions & 0 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,9 @@ def test_unselect
imap.search(["SUBJECT", "1,*"])
assert_equal 'SUBJECT "1,*"', server.commands.pop.args

imap.search(["subject", "hello", Set[1, 2, 3, 4, 5, 8, *(10..100)]])
assert_equal "subject hello 1:5,8,10:100", server.commands.pop.args

server.on "UID SEARCH", &search_resp
assert_equal search_result, imap.uid_search(["subject", "hello",
[1..22, 30..-1]])
Expand Down

0 comments on commit 2db20a7

Please sign in to comment.