Files
nairobi/lib/tag_sanitizer.rb
kikito c750765bca Modifies the tag sanitizer to truncate tags longer than 40
I could not make a nice ActAsTaggable error message, this is way faster
2015-09-09 18:30:27 +02:00

19 lines
318 B
Ruby

class TagSanitizer
TAG_MAX_LENGTH = 40
DISALLOWED_STRINGS = %w(? < > = /)
def sanitize_tag(tag)
tag = tag.dup
DISALLOWED_STRINGS.each do |s|
tag.gsub!(s, '')
end
tag.truncate(TAG_MAX_LENGTH)
end
def sanitize_tag_list(tag_list)
tag_list.map { |tag| sanitize_tag(tag) }
end
end