diff --git a/lib/will_paginate/view_helpers.rb b/lib/will_paginate/view_helpers.rb index 911655604..bb87a41a1 100644 --- a/lib/will_paginate/view_helpers.rb +++ b/lib/will_paginate/view_helpers.rb @@ -332,21 +332,21 @@ def url_for(page) return url if page_one if complex - @url_string = url.sub(%r!((?:\?|&)#{CGI.escape param_name}=)#{page}!, '\1@') + @url_string = url.sub(%r!((?:\?|&)#{CGI.escape param_name}=)#{page}!, "\\1\0") return url else @url_string = url @url_params[param_name] = 3 @template.url_for(@url_params).split(//).each_with_index do |char, i| if char == '3' and url[i, 1] == '2' - @url_string[i] = '@' + @url_string[i] = "\0" break end end end end # finally! - @url_string.sub '@', page.to_s + @url_string.sub "\0", page.to_s end private diff --git a/test/view_test.rb b/test/view_test.rb index 3ada45795..3777cced7 100644 --- a/test/view_test.rb +++ b/test/view_test.rb @@ -277,6 +277,14 @@ def test_will_paginate_with_custom_page_param end end end + + def test_will_paginate_with_atmark_url + @request.symbolized_path_parameters[:action] = "@tag" + renderer = WillPaginate::LinkRenderer.new + + paginate({ :page => 1 }, :renderer=>renderer) + assert_links_match %r[/foo/@tag\?page=\d] + end def test_complex_custom_page_param @request.params :developers => { :page => 2 }