Skip to content
Open
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
15 changes: 15 additions & 0 deletions lib/restpack_serializer/serializable/paging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,23 @@ def page_href(page, options)
params << options.sorting_as_url_params if options.sorting.any?
params << options.filters_as_url_params if options.filters.any?

params = escape_params(params)

url += '?' + params.join('&') if params.any?
url
end

def escape_params(params)
params.map do |param|
escape_param(param)
end.flatten
end

def escape_param(param_string)
param_string.split('&').map do |param|
key, value = param.split('=')
"#{key}=#{CGI::escape value}"
end
end
end
end
2 changes: 1 addition & 1 deletion spec/serializable/paging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
end

it "includes the side-loads in page hrefs" do
page[:meta][:songs][:next_href].should == '/songs?page=2&include=albums,artists'
page[:meta][:songs][:next_href].should == '/songs?page=2&include=albums%2Cartists'
end

it "includes links" do
Expand Down