diff options
-rw-r--r-- | lib/gitlab/markdown/autolink_filter.rb | 5 | ||||
-rw-r--r-- | spec/features/markdown_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/markdown/autolink_filter_spec.rb | 8 |
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/gitlab/markdown/autolink_filter.rb b/lib/gitlab/markdown/autolink_filter.rb index 9889d6643ab..f0b68bab825 100644 --- a/lib/gitlab/markdown/autolink_filter.rb +++ b/lib/gitlab/markdown/autolink_filter.rb @@ -52,7 +52,10 @@ module Gitlab # NOTE: We don't parse email links because it will erroneously match # external Commit and CommitRange references. - rinku = Rinku.auto_link(html, :urls, options, IGNORE_PARENTS.to_a) + # + # The final argument tells Rinku to link short URLs that don't include a + # period (e.g., http://localhost:3000/) + rinku = Rinku.auto_link(html, :urls, options, IGNORE_PARENTS.to_a, 1) # Rinku returns a String, so parse it back to a Nokogiri::XML::Document # for further processing. diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 9db1a0a2418..3528200e12b 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -207,11 +207,9 @@ describe 'GitLab Markdown' do expect(item(5).children.first['href']).to eq 'irc://irc.freenode.net/git' end - # TODO (rspeicher): Do we really want this? it 'autolinks short, invalid URLs' do - skip 'rspeicher: Pending decision' expect(item(6).children.first.name).to eq 'a' - expect(item(6).children.first['href']).to eq 'http://foo' + expect(item(6).children.first['href']).to eq 'http://localhost:3000' end %w(code a kbd).each do |elem| diff --git a/spec/lib/gitlab/markdown/autolink_filter_spec.rb b/spec/lib/gitlab/markdown/autolink_filter_spec.rb index 83fee123330..0bbdc11a979 100644 --- a/spec/lib/gitlab/markdown/autolink_filter_spec.rb +++ b/spec/lib/gitlab/markdown/autolink_filter_spec.rb @@ -41,6 +41,14 @@ module Gitlab::Markdown expect(doc.at_css('a')['href']).to eq link end + it 'autolinks short URLs' do + link = 'http://localhost:3000/' + doc = filter("See #{link}") + + expect(doc.at_css('a').text).to eq link + expect(doc.at_css('a')['href']).to eq link + end + it 'accepts link_attr options' do doc = filter("See #{link}", link_attr: {class: 'custom'}) |