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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
4a9a163c
Commit
4a9a163c
authored
Jan 13, 2022
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip + reference format from HTML links
so that the links are valid Changelog: fixed
parent
e14d2414
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
3 deletions
+13
-3
ee/spec/lib/banzai/filter/references/epic_reference_filter_spec.rb
...ib/banzai/filter/references/epic_reference_filter_spec.rb
+5
-2
lib/banzai/filter/references/abstract_reference_filter.rb
lib/banzai/filter/references/abstract_reference_filter.rb
+2
-0
spec/lib/banzai/filter/references/issue_reference_filter_spec.rb
...b/banzai/filter/references/issue_reference_filter_spec.rb
+2
-0
spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb
.../filter/references/merge_request_reference_filter_spec.rb
+4
-1
No files found.
ee/spec/lib/banzai/filter/references/epic_reference_filter_spec.rb
View file @
4a9a163c
...
...
@@ -21,6 +21,7 @@ RSpec.describe Banzai::Filter::References::EpicReferenceFilter do
context
'internal reference'
do
let
(
:reference
)
{
"&
#{
epic
.
iid
}
"
}
let
(
:epic_url
)
{
urls
.
group_epic_url
(
group
,
epic
)
}
it
'links to a valid reference'
do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
(
urls
.
group_epic_url
(
group
,
epic
))
...
...
@@ -66,17 +67,19 @@ RSpec.describe Banzai::Filter::References::EpicReferenceFilter do
end
it
'includes a data-reference-format attribute'
do
link
=
doc
(
"
&
#{
epic
.
iid
}
+"
).
css
(
'a'
).
first
link
=
doc
(
"
#{
reference
}
+"
).
css
(
'a'
).
first
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
epic_url
)
end
it
'includes a data-reference-format attribute for URL references'
do
link
=
doc
(
"
#{
urls
.
group_epic_url
(
group
,
epic
)
}
+"
).
css
(
'a'
).
first
link
=
doc
(
"
#{
epic_url
}
+"
).
css
(
'a'
).
first
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
epic_url
)
end
it
'ignores invalid epic IIDs'
do
...
...
lib/banzai/filter/references/abstract_reference_filter.rb
View file @
4a9a163c
...
...
@@ -216,6 +216,8 @@ module Banzai
url_for_object_cached
(
object
,
parent
)
end
url
.
chomp!
(
matches
[
:format
])
if
matches
.
names
.
include?
(
"format"
)
content
=
link_content
||
object_link_text
(
object
,
matches
)
link
=
%(<a href="#{url}" #{data}
...
...
spec/lib/banzai/filter/references/issue_reference_filter_spec.rb
View file @
4a9a163c
...
...
@@ -122,6 +122,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
issue_url
)
end
it
'includes a data-reference-format attribute for URL references'
do
...
...
@@ -130,6 +131,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
issue_url
)
end
it
'supports an :only_path context'
do
...
...
spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb
View file @
4a9a163c
...
...
@@ -51,6 +51,7 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do
context
'internal reference'
do
let
(
:reference
)
{
merge
.
to_reference
}
let
(
:merge_request_url
)
{
urls
.
project_merge_request_url
(
project
,
merge
)
}
it
'links to a valid reference'
do
doc
=
reference_filter
(
"See
#{
reference
}
"
)
...
...
@@ -115,14 +116,16 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
merge_request_url
)
end
it
'includes a data-reference-format attribute for URL references'
do
doc
=
reference_filter
(
"Merge
#{
urls
.
project_merge_request_url
(
project
,
merge
)
}
+"
)
doc
=
reference_filter
(
"Merge
#{
merge_request_url
}
+"
)
link
=
doc
.
css
(
'a'
).
first
expect
(
link
).
to
have_attribute
(
'data-reference-format'
)
expect
(
link
.
attr
(
'data-reference-format'
)).
to
eq
(
'+'
)
expect
(
link
.
attr
(
'href'
)).
to
eq
(
merge_request_url
)
end
it
'supports an :only_path context'
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