Commit 09e901c9 authored by Jonathan Schafer's avatar Jonathan Schafer Committed by Dmytro Zaporozhets

Remove colon from Vulnerability file name if no line number exists

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