diff --git a/lib/email_cook.rb b/lib/email_cook.rb
index 48aea344545..03f40ea2a10 100644
--- a/lib/email_cook.rb
+++ b/lib/email_cook.rb
@@ -3,7 +3,7 @@
class EmailCook
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
def initialize(raw)
diff --git a/spec/components/email_cook_spec.rb b/spec/components/email_cook_spec.rb
new file mode 100644
index 00000000000..a440fbf7923
--- /dev/null
+++ b/spec/components/email_cook_spec.rb
@@ -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
world\n
")
+ end
+
+ it 'autolinks' do
+ expect(EmailCook.new("https://www.eviltrout.com").cook).to eq("https://www.eviltrout.com
")
+ end
+end