summaryrefslogtreecommitdiff
path: root/app/services/projects/import_error_filter.rb
blob: a0fc5149bb4e713c64fb7251b557c8440447d0df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

module Projects
  # Used by project imports, it removes any potential paths
  # included in an error message that could be stored in the DB
  class ImportErrorFilter
    ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/
    FILTER_MESSAGE = '[FILTERED]'

    def self.filter_message(message)
      message.gsub(ERROR_MESSAGE_FILTER, FILTER_MESSAGE)
    end
  end
end