Skip to content

Commit

Permalink
Link should be separated by comma.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed May 31, 2024
1 parent 8dc7a7f commit 3922460
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def headers
#
# The `send_early_hints` method accepts a hash of links as follows:
#
# send_early_hints("link" => "</style.css>; rel=preload; as=style\n</script.js>; rel=preload")
# send_early_hints("link" => "</style.css>; rel=preload; as=style,</script.js>; rel=preload")
#
# If you are using `javascript_include_tag` or `stylesheet_link_tag` the Early
# Hints headers are included by default if supported.
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/dispatch/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,8 @@ def setup
end

test "when early hints is set in the env link headers are sent" do
early_hints = @request.send_early_hints("link" => "</style.css>; rel=preload; as=style\n</script.js>; rel=preload")
expected_hints = { "link" => "</style.css>; rel=preload; as=style\n</script.js>; rel=preload" }
early_hints = @request.send_early_hints("link" => "</style.css>; rel=preload; as=style,</script.js>; rel=preload")
expected_hints = { "link" => "</style.css>; rel=preload; as=style,</script.js>; rel=preload" }

assert_equal expected_hints, early_hints
end
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/asset_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def send_preload_links_header(preload_links, max_header_size: MAX_HEADER_SIZE)
return if response_present && response.sending?

if respond_to?(:request) && request
request.send_early_hints("link" => preload_links.join("\n"))
request.send_early_hints("link" => preload_links.join(","))
end

if response_present
Expand Down

0 comments on commit 3922460

Please sign in to comment.