module ActionView::Helpers::UrlHelper
Public Instance Methods
convert_options_to_data_attributes(options, html_options)
click to toggle source
# File lib/safe_target_blank/url_helper.rb, line 25 def convert_options_to_data_attributes(options, html_options) if html_options html_options = html_options.stringify_keys if link_to_target_blank?(html_options) rel = link_to_target_blank_default_rel(html_options).presence html_options['rel'] = rel if rel end end original_convert_options_to_data_attributes(options, html_options) end
Also aliased as: original_convert_options_to_data_attributes
link_to_option_enabled?(html_options, option)
click to toggle source
# File lib/safe_target_blank/url_helper.rb, line 14 def link_to_option_enabled?(html_options, option) html_options.is_a?(Hash) && (html_options.delete(option.to_s) || html_options.delete(option.to_sym)) end
link_to_rel_from_html_options(html_options)
click to toggle source
# File lib/safe_target_blank/url_helper.rb, line 10 def link_to_rel_from_html_options(html_options) html_options['rel'].is_a?(Array) ? html_options['rel'].map(&:to_s) : html_options['rel'].to_s.split(' ') end
link_to_target_blank?(html_options)
click to toggle source
# File lib/safe_target_blank/url_helper.rb, line 6 def link_to_target_blank?(html_options) html_options['target'] && html_options['target'].to_s.include?('_blank') end
link_to_target_blank_default_rel(html_options)
click to toggle source
# File lib/safe_target_blank/url_helper.rb, line 18 def link_to_target_blank_default_rel(html_options) rel = link_to_rel_from_html_options(html_options) rel.push('noopener') if !SafeTargetBlank.opener && !link_to_option_enabled?(html_options, 'opener') rel.push('noreferrer') if !SafeTargetBlank.referrer && !link_to_option_enabled?(html_options, 'referrer') rel.map(&:presence).compact.uniq.join(' ') end
original_convert_options_to_data_attributes(options, html_options)
Alias for: convert_options_to_data_attributes