Skip to content

Commit

Permalink
Rack 3 does not allow newlines in headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dentarg committed Apr 11, 2023
1 parent cf9b972 commit a0f18dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions sinatra-contrib/lib/sinatra/link_header.rb
Expand Up @@ -89,10 +89,10 @@ def link(*urls)
link = (response['Link'] ||= '')

urls.map do |url|
link << ",\n" unless link.empty?
link << "," unless link.empty?
link << (http_pattern % url)
html_pattern % url
end.join "\n"
end.join
end

##
Expand All @@ -117,10 +117,10 @@ def link_headers
yield if block_given?
return '' unless response.include? 'Link'

response['Link'].split(",\n").map do |line|
response['Link'].split(",").map do |line|
url, *opts = line.split(';').map(&:strip)
"<link href=\"#{url[1..-2]}\" #{opts.join ' '} />"
end.join "\n"
end.join
end

def self.registered(_base)
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'].split(",\n").first.strip.split('; ').sort).to eq(elements)
expect(headers['Link'].split(",").first.strip.split('; ').sort).to eq(elements)
end
end

Expand Down

0 comments on commit a0f18dd

Please sign in to comment.