Commit cd3c24a8 authored by Robert Speicher's avatar Robert Speicher

Autolink short URLs

parent f4fac3ac
......@@ -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.
......
......@@ -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|
......
......@@ -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'})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment