FIX: Autolinking in email formatter was broken

This commit is contained in:
Robin Ward 2016-07-12 13:33:13 -04:00
parent c2b769bd95
commit 0c3b049176
2 changed files with 14 additions and 1 deletions

View file

@ -3,7 +3,7 @@
class EmailCook class EmailCook
def self.url_regexp def self.url_regexp
/[^\>]*((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.])(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»\s]))/ /^((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.])(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»“”‘’\s]))/
end end
def initialize(raw) def initialize(raw)

View file

@ -0,0 +1,13 @@
require 'rails_helper'
require 'email_cook'
describe EmailCook do
it 'adds linebreaks' do
expect(EmailCook.new("hello\nworld\n").cook).to eq("hello\n<br>world\n<br>")
end
it 'autolinks' do
expect(EmailCook.new("https://www.eviltrout.com").cook).to eq("<a href='https://www.eviltrout.com'>https://www.eviltrout.com</a><br>")
end
end