# Destructively replaces email addresses into clickable links
def auto_mailto!(text)
- text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
+ text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
mail = $1
if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
mail
assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '')
end
+ def test_should_link_email_with_slashes
+ raw = 'foo/bar@example.net'
+ expected = '<p><a class="email" href="mailto:foo/bar@example.net">foo/bar@example.net</a></p>'
+ assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '')
+ end
+
def test_links_separated_with_line_break_should_link
raw = <<-DIFF
link: https://www.redmine.org