gitlab-org--gitlab-foss/app/controllers/concerns/snippets_actions.rb
2017-02-20 07:24:03 +01:00

21 lines
403 B
Ruby

module SnippetsActions
extend ActiveSupport::Concern
def edit
end
def raw
send_data(
convert_line_endings(@snippet.content),
type: 'text/plain; charset=utf-8',
disposition: 'inline',
filename: @snippet.sanitized_file_name
)
end
private
def convert_line_endings(content)
params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n")
end
end