Skip to content

Commit

Permalink
Merge branch 'change-link-header-delimiter-to-comma-and-newline' of h…
Browse files Browse the repository at this point in the history
…ttps://github.com/petedmarsh/sinatra-contrib into petedmarsh-change-link-header-delimiter-to-comma-and-newline
  • Loading branch information
Zachary Scott committed Jul 21, 2016
2 parents 5a4cba9 + 1d28112 commit d0d392c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sinatra-contrib/lib/sinatra/link_header.rb
Expand Up @@ -90,7 +90,7 @@ def link(*urls)
link = (response["Link"] ||= "")

urls.map do |url|
link << "\n" unless link.empty?
link << ",\n" unless link.empty?
link << (http_pattern % url)
html_pattern % url
end.join "\n"
Expand All @@ -117,7 +117,7 @@ def link(*urls)
def link_headers
yield if block_given?
return "" unless response.include? "Link"
response["Link"].lines.map do |line|
response["Link"].split(",\n").map do |line|
url, *opts = line.split(';').map(&:strip)
"<link href=\"#{url[1..-2]}\" #{opts.join " "} />"
end.join "\n"
Expand Down
2 changes: 1 addition & 1 deletion sinatra-contrib/spec/link_header_spec.rb
Expand Up @@ -41,7 +41,7 @@
it "takes an options hash" do
get '/'
elements = ["<something>", "foo=\"bar\"", "rel=\"from-filter\""]
expect(headers['Link'].lines.first.strip.split('; ').sort).to eq(elements)
expect(headers['Link'].split(",\n").first.strip.split('; ').sort).to eq(elements)
end
end

Expand Down

0 comments on commit d0d392c

Please sign in to comment.