A platform for community discussion. Free, open, simple.
DEV: Fix syntax for Link entity header for `experimental_preconnect_link_header` (#26218)
Alan Guo Xiang Tan27b0ebff4cb1
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex ad37850f046..089b3c00420 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -1108,9 +1108,9 @@ class ApplicationController < ActionController::Basenext if url.blank?base_url = URI.join(url, "/").to_s.chomp("/")- links.push("<#{base_url}>; rel=preconnect;")+ links.push("<#{base_url}>; rel=preconnect")# Not all browsers support the preconnect resource hint so we are adding dns-prefetch as the fallback- links.push("<#{base_url}>; rel=dns-prefetch;")+ links.push("<#{base_url}>; rel=dns-prefetch")endenddiff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rbindex a280710c75f..be4e3d2ccd9 100644--- a/spec/requests/application_controller_spec.rb+++ b/spec/requests/application_controller_spec.rb@@ -1200,7 +1200,7 @@ RSpec.describe ApplicationController doexpect(response.status).to eq(200)expect(response.headers["Link"]).to include(- "<https://cdn.example.com>; rel=preconnect;, <https://cdn.example.com>; rel=dns-prefetch;",+ "<https://cdn.example.com>; rel=preconnect, <https://cdn.example.com>; rel=dns-prefetch",)end@@ -1212,7 +1212,7 @@ RSpec.describe ApplicationController doexpect(response.status).to eq(200)expect(response.headers["Link"]).to include(- "<https://s3.some-cdn.com>; rel=preconnect;, <https://s3.some-cdn.com>; rel=dns-prefetch;",+ "<https://s3.some-cdn.com>; rel=preconnect, <https://s3.some-cdn.com>; rel=dns-prefetch",)endend