Skip to content

Commit bd629d6

Browse files
authored
Fix nonce attributes that were accidentally broken in 243fbfb (#143)
It seems that 243fbfb accidentally swapped `content_security_policy_nonce` with `content_security_policy`, so we're switching them back to call `content_security_policy_nonce`.
1 parent a615b27 commit bd629d6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/helpers/importmap/importmap_tags_helper.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def javascript_importmap_tags(entry_point = "application", shim: true)
1414
# By default, `Rails.application.importmap.to_json(resolver: self)` is used.
1515
def javascript_inline_importmap_tag(importmap_json = Rails.application.importmap.to_json(resolver: self))
1616
tag.script importmap_json.html_safe,
17-
type: "importmap", "data-turbo-track": "reload", nonce: request&.content_security_policy
17+
type: "importmap", "data-turbo-track": "reload", nonce: request&.content_security_policy_nonce
1818
end
1919

2020
# Configure es-modules-shim with nonce support if the application is using a content security policy.
@@ -28,14 +28,14 @@ def javascript_importmap_shim_nonce_configuration_tag
2828
# Include the es-modules-shim needed to make importmaps work in browsers without native support (like Firefox + Safari).
2929
def javascript_importmap_shim_tag(minimized: true)
3030
javascript_include_tag minimized ? "es-module-shims.min.js" : "es-module-shims.js",
31-
async: true, "data-turbo-track": "reload", nonce: request&.content_security_policy
31+
async: true, "data-turbo-track": "reload", nonce: request&.content_security_policy_nonce
3232
end
3333

3434
# Import a named JavaScript module(s) using a script-module tag.
3535
def javascript_import_module_tag(*module_names)
3636
imports = Array(module_names).collect { |m| %(import "#{m}") }.join("\n")
3737
tag.script imports.html_safe,
38-
type: "module", nonce: request&.content_security_policy
38+
type: "module", nonce: request&.content_security_policy_nonce
3939
end
4040

4141
# Link tags for preloading all modules marked as preload: true in the `importmap`
@@ -48,7 +48,7 @@ def javascript_importmap_module_preload_tags(importmap = Rails.application.impor
4848
# Link tag(s) for preloading the JavaScript module residing in `*paths`. Will return one link tag per path element.
4949
def javascript_module_preload_tag(*paths)
5050
safe_join(Array(paths).collect { |path|
51-
tag.link rel: "modulepreload", href: path, nonce: request&.content_security_policy
51+
tag.link rel: "modulepreload", href: path, nonce: request&.content_security_policy_nonce
5252
}, "\n")
5353
end
5454
end

0 commit comments

Comments
 (0)