Skip to content

Commit c02f1b0

Browse files
committed
add extra safety so offset can not be negative
1 parent 9981257 commit c02f1b0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/topic_query.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def prioritize_pinned_topics(topics, options)
170170
if page == 0
171171
(pinned_topics + unpinned_topics)[0...limit] if limit
172172
else
173-
unpinned_topics.offset((page * per_page - pinned_topics.count) - 1).to_a
173+
offset = (page * per_page - pinned_topics.count) - 1
174+
offset = 0 unless offset > 0
175+
unpinned_topics.offset(offset).to_a
174176
end
175177

176178
end

0 commit comments

Comments
 (0)