Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
cd3c24a8
Commit
cd3c24a8
authored
Apr 29, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autolink short URLs
parent
f4fac3ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
lib/gitlab/markdown/autolink_filter.rb
lib/gitlab/markdown/autolink_filter.rb
+4
-1
spec/features/markdown_spec.rb
spec/features/markdown_spec.rb
+1
-3
spec/lib/gitlab/markdown/autolink_filter_spec.rb
spec/lib/gitlab/markdown/autolink_filter_spec.rb
+8
-0
No files found.
lib/gitlab/markdown/autolink_filter.rb
View file @
cd3c24a8
...
...
@@ -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.
...
...
spec/features/markdown_spec.rb
View file @
cd3c24a8
...
...
@@ -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
|
...
...
spec/lib/gitlab/markdown/autolink_filter_spec.rb
View file @
cd3c24a8
...
...
@@ -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'
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment