1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Merge branch 'change-link-header-delimiter-to-comma-and-newline' of https://github.com/petedmarsh/sinatra-contrib into petedmarsh-change-link-header-delimiter-to-comma-and-newline

This commit is contained in:
Zachary Scott 2016-07-21 18:40:49 +09:00
commit d0d392c13c
2 changed files with 3 additions and 3 deletions

View file

@ -90,7 +90,7 @@ module Sinatra
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"
@ -117,7 +117,7 @@ module Sinatra
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"

View file

@ -41,7 +41,7 @@ describe Sinatra::LinkHeader do
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