This commit is contained in:
MrZYX 2010-12-13 14:22:57 +01:00
parent 390587777f
commit 1284fcc92d
2 changed files with 8 additions and 2 deletions

View file

@ -193,8 +193,8 @@ module ApplicationHelper
end
if options[:autolinks]
message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2')
message.gsub!(/(<a target="\\?_blank" href=")?(https|http|ftp):\/\/([^ ]+)/) do |m|
message.gsub!(/( |^)(www\.[^\s]+\.[^\s])/, '\1http://\2')
message.gsub!(/(<a target="\\?_blank" href=")?(https|http|ftp):\/\/([^\s]+)/) do |m|
if !$1.nil?
m
else

View file

@ -208,6 +208,12 @@ describe ApplicationHelper do
res = markdownify(message)
res.should == "These<br /\>are<br /\>some<br /\>new<br /\>lines"
end
it 'should render newlines and basic http links correctly' do
message = "Some text, then a line break and a link\nhttp://joindiaspora.com\nsome more text"
res = markdownify(message)
res.should == 'Some text, then a line break and a link<br /><a target="_blank" href="http://joindiaspora.com">joindiaspora.com</a><br />some more text'
end
end
context 'performance' do