Skip to content

Commit

Permalink
fix: duplicate entries when using min_width or max_width (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherwinski authored Nov 20, 2019
1 parent a5578d8 commit c762fc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/imgix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Imgix
resolutions = []
prev = min || MIN_WIDTH

while(prev <= max_size)
while(prev < max_size)
# ensures that each width is even
resolutions.push((2 * (prev / 2).round))
prev *= 1 + (increment_percentage * 2)
Expand Down
9 changes: 9 additions & 0 deletions test/units/srcset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,16 @@ def test_only_max

assert_operator min, :>=, min_width
assert_operator max, :<=, max_width
end

def test_max_as_100
srcset = Imgix::Client.new(host: 'testing.imgix.net', include_library_param: false).path('image.jpg').to_srcset(options: {max_width: 100})
assert_equal(srcset, "https://testing.imgix.net/image.jpg?w=100 100w")
end

def test_min_as_8192
srcset = Imgix::Client.new(host: 'testing.imgix.net', include_library_param: false).path('image.jpg').to_srcset(options: {min_width: 8192})
assert_equal(srcset, "https://testing.imgix.net/image.jpg?w=8192 8192w")
end

private
Expand Down

0 comments on commit c762fc1

Please sign in to comment.