Skip to content

Commit

Permalink
Fixed param replacement boundary issue [#22]
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 27, 2009
1 parent b15ce2f commit 59a2c32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/dm-pager/pager.rb
Expand Up @@ -183,9 +183,9 @@ def li css_class = nil, contents = nil


def uri_for page def uri_for page
case @uri case @uri
when /page=/ ; @uri.gsub /page=\d+/, "page=#{page}" when /\bpage=/ ; @uri.gsub /\bpage=\d+/, "page=#{page}"
when /\?/ ; @uri += "&page=#{page}" when /\?/ ; @uri += "&page=#{page}"
else ; @uri += "?page=#{page}" else ; @uri += "?page=#{page}"
end end
end end


Expand Down
9 changes: 9 additions & 0 deletions spec/unit/pager_spec.rb
Expand Up @@ -214,6 +214,15 @@
markup.should include('items?foo=bar&page=1') markup.should include('items?foo=bar&page=1')
end end
end end

describe "when containing other keys with 'page'" do
it "should append a pair" do
markup = Item.page.pager.to_html 'items?per_page=5'
markup.should include('items?per_page=5&page=1')
markup = Item.page.pager.to_html 'items?page=4&per_page=3'
markup.should include('items?page=1&per_page=3')
end
end
end end


end end
Expand Down

0 comments on commit 59a2c32

Please sign in to comment.