Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 7f3e78f3a81..6aafd856423 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -60,9 +60,14 @@ module DiffHelper
if line.blank?
" ".html_safe
else
- # We can't use `sub` because the HTML-safeness of `line` will not survive.
- line[0] = '' if line.start_with?('+', '-', ' ')
- line
+ # `sub` and substring-ing would destroy HTML-safeness of `line`
+ if line.start_with?('+', '-', ' ')
+ line.dup.tap do |line|
+ line[0] = ''
+ end
+ else
+ line
+ end
end
end