class ConfidentialInfoRedactor::Hyperlink
Constants
- HYPERLINK_REGEX
Rubular: rubular.com/r/fXa4lp0gfS
- NON_HYPERLINK_REGEX
Public Instance Methods
hyperlink?(text)
click to toggle source
# File lib/confidential_info_redactor/hyperlink.rb, line 10 def hyperlink?(text) !(text !~ URI.regexp) && text !~ NON_HYPERLINK_REGEX && !(text !~ HYPERLINK_REGEX) end
replace(text)
click to toggle source
# File lib/confidential_info_redactor/hyperlink.rb, line 14 def replace(text) text.split(/\s+/).map { |token| text = text.gsub(/#{Regexp.escape(token.gsub(/\.\z/, ''))}/, ' <redacted> ') if !(token !~ HYPERLINK_REGEX) } text end