Change `prohibited_key` to use regexes
This commit is contained in:
parent
4b46b53082
commit
0aff6238f7
|
@ -4,7 +4,7 @@ module Gitlab
|
||||||
module ImportExport
|
module ImportExport
|
||||||
class AttributeCleaner
|
class AttributeCleaner
|
||||||
ALLOWED_REFERENCES = RelationFactory::PROJECT_REFERENCES + RelationFactory::USER_REFERENCES + ['group_id']
|
ALLOWED_REFERENCES = RelationFactory::PROJECT_REFERENCES + RelationFactory::USER_REFERENCES + ['group_id']
|
||||||
PROHIBITED_SUFFIXES = %w[_id _html].freeze
|
PROHIBITED_REFERENCES = Regexp.union(/\Acached_markdown_version\Z/, /_id\Z/, /_html\Z/).freeze
|
||||||
|
|
||||||
def self.clean(*args)
|
def self.clean(*args)
|
||||||
new(*args).clean
|
new(*args).clean
|
||||||
|
@ -25,9 +25,7 @@ module Gitlab
|
||||||
private
|
private
|
||||||
|
|
||||||
def prohibited_key?(key)
|
def prohibited_key?(key)
|
||||||
return false if permitted_key?(key)
|
key =~ PROHIBITED_REFERENCES && !permitted_key?(key)
|
||||||
|
|
||||||
'cached_markdown_version' == key || PROHIBITED_SUFFIXES.any? {|suffix| key.end_with?(suffix)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def permitted_key?(key)
|
def permitted_key?(key)
|
||||||
|
|
Loading…
Reference in New Issue