feat(flash messages): add a helper method to keep link when sanitizing

This commit is contained in:
Eric Leroy-Terquem 2023-02-23 10:07:09 +01:00
parent 28c6fd8cfc
commit 127f86e8ae
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,6 @@
module SanitizeWithLinkHelper
def sanitize_with_link(value)
tags = Rails.configuration.action_view.sanitized_allowed_tags + ['a']
sanitize(value, tags:)
end
end

View file

@ -7,8 +7,8 @@
- if value.class == Array - if value.class == Array
.alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) } .alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) }
- value.each do |message| - value.each do |message|
= sanitize(message) = sanitize_with_link(message)
%br %br
- else - else
.alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) } .alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) }
= sanitize(value) = sanitize_with_link(value)