Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/vers/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ def parse_hex_range(range_string)
end

def parse_hex_single_range(range_string)
# Handle "and" conjunction
if range_string.include?(" and ")
and_parts = range_string.split(" and ").map(&:strip)
# Handle "and" conjunction and comma-separated AND constraints
if range_string.include?(" and ") || range_string.include?(",")
and_parts = range_string.split(/\s+and\s+|,/).map(&:strip).reject(&:empty?)
ranges = and_parts.map { |part| parse_hex_constraint(part) }
return ranges.reduce { |acc, range| acc.intersect(range) }
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,14 @@ def test_parse_native_hex_and_conjunction
refute range.contains?("2.0.0")
end

def test_parse_native_hex_comma_separated_conjunction
range = @parser.parse_native(">= 3.6.3, <= 3.7.0", "hex")
assert range.contains?("3.6.3")
assert range.contains?("3.7.0")
refute range.contains?("3.6.2")
refute range.contains?("3.7.1")
end

def test_parse_native_hex_or_disjunction
range = @parser.parse_native("~> 1.0 or ~> 2.0", "hex")
assert range.contains?("1.5.0")
Expand Down