Commit 55463cde authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch...

Merge branch '214501-file-location-of-vulnerability-shows-colon-after-file-if-no-line-number-exists' into 'master'

Remove colon from Vulnerability file name if no line number exists

See merge request gitlab-org/gitlab!30069
parents 8c9edd63 09e901c9
......@@ -49,9 +49,13 @@ module VulnerabilitiesHelper
finding = vulnerability.finding
location = finding.location
branch = finding.pipelines&.last&.sha || vulnerability.project.default_branch
link_text = "#{location['file']}:#{location['start_line']}"
offset = location['start_line'] ? "#L#{location['start_line']}" : ''
link_path = project_blob_path(vulnerability.project, tree_join(branch, location['file'])) + offset
link_text = location['file']
link_path = project_blob_path(vulnerability.project, tree_join(branch, location['file']))
if location['start_line']
link_text += ":#{location['start_line']}"
link_path += "#L#{location['start_line']}"
end
link_to link_text, link_path, target: '_blank', rel: 'noopener noreferrer'
end
......
......@@ -150,6 +150,7 @@ describe VulnerabilitiesHelper do
vulnerability.finding.save
expect(subject).not_to include('#L')
expect(subject).not_to match(/#{vulnerability.finding.location['file']}:\d*/)
end
end
end
......
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