BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7d157642
Commit
7d157642
authored
Mar 29, 2018
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cherry-pick-058dd1' into '10-6-stable'
[10.6] Autolinking includes trailing exclamation marks See merge request gitlab-org/gitlab-ce!18077
parents
4380c0e7
60c5c8a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
13 deletions
+15
-13
44587-autolinking-includes-trailing-exclamation-marks.yml
...44587-autolinking-includes-trailing-exclamation-marks.yml
+5
-0
autolink_filter.rb
lib/banzai/filter/autolink_filter.rb
+6
-5
autolink_filter_spec.rb
spec/lib/banzai/filter/autolink_filter_spec.rb
+4
-8
No files found.
changelogs/unreleased/44587-autolinking-includes-trailing-exclamation-marks.yml
0 → 100644
View file @
7d157642
---
title
:
Don't capture trailing punctuation when autolinking
merge_request
:
17965
author
:
type
:
fixed
lib/banzai/filter/autolink_filter.rb
View file @
7d157642
...
...
@@ -21,12 +21,13 @@ module Banzai
#
# See http://en.wikipedia.org/wiki/URI_scheme
#
# The negative lookbehind ensures that users can paste a URL followed by a
# period or comma for punctuation without those characters being included
# in the generated link.
# The negative lookbehind ensures that users can paste a URL followed by
# punctuation without those characters being included in the generated
# link. It matches the behaviour of Rinku 2.0.1:
# https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65
#
# Rubular: http://rubular.com/r/
JzPhi6DCZp
LINK_PATTERN
=
%r{([a-z][a-z0-9
\+\.
-]+://[^
\s
>]+)(?<!
,|
\.
)}
# Rubular: http://rubular.com/r/
nrL3r9yUiq
LINK_PATTERN
=
%r{([a-z][a-z0-9
\+\.
-]+://[^
\s
>]+)(?<!
\?
|!|
\.
|,|:
)}
# Text matching LINK_PATTERN inside these elements will not be linked
IGNORE_PARENTS
=
%w(a code kbd pre script style)
.
to_set
...
...
spec/lib/banzai/filter/autolink_filter_spec.rb
View file @
7d157642
...
...
@@ -122,14 +122,10 @@ describe Banzai::Filter::AutolinkFilter do
end
it
'does not include trailing punctuation'
do
doc
=
filter
(
"See
#{
link
}
."
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
doc
=
filter
(
"See
#{
link
}
, ok?"
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
doc
=
filter
(
"See
#{
link
}
..."
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
[
'.'
,
', ok?'
,
'...'
,
'?'
,
'!'
,
': is that ok?'
].
each
do
|
trailing_punctuation
|
doc
=
filter
(
"See
#{
link
}#{
trailing_punctuation
}
"
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
end
end
it
'includes trailing punctuation when part of a balanced pair'
do
...
...
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