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:
commit
d0d392c13c
|
@ -90,7 +90,7 @@ module Sinatra
|
||||||
link = (response["Link"] ||= "")
|
link = (response["Link"] ||= "")
|
||||||
|
|
||||||
urls.map do |url|
|
urls.map do |url|
|
||||||
link << "\n" unless link.empty?
|
link << ",\n" unless link.empty?
|
||||||
link << (http_pattern % url)
|
link << (http_pattern % url)
|
||||||
html_pattern % url
|
html_pattern % url
|
||||||
end.join "\n"
|
end.join "\n"
|
||||||
|
@ -117,7 +117,7 @@ module Sinatra
|
||||||
def link_headers
|
def link_headers
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
return "" unless response.include? "Link"
|
return "" unless response.include? "Link"
|
||||||
response["Link"].lines.map do |line|
|
response["Link"].split(",\n").map do |line|
|
||||||
url, *opts = line.split(';').map(&:strip)
|
url, *opts = line.split(';').map(&:strip)
|
||||||
"<link href=\"#{url[1..-2]}\" #{opts.join " "} />"
|
"<link href=\"#{url[1..-2]}\" #{opts.join " "} />"
|
||||||
end.join "\n"
|
end.join "\n"
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe Sinatra::LinkHeader do
|
||||||
it "takes an options hash" do
|
it "takes an options hash" do
|
||||||
get '/'
|
get '/'
|
||||||
elements = ["<something>", "foo=\"bar\"", "rel=\"from-filter\""]
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue