lib/flapjack.rb in flapjack-1.3.0 vs lib/flapjack.rb in flapjack-1.4.0rc1
- old
+ new
@@ -13,7 +13,13 @@
def self.dump_json(data)
Oj.dump(data, :mode => :compat, :time_format => :ruby, :indent => 0)
end
+ def self.sanitize(str)
+ return str if str.nil? || !str.is_a?(String) || str.valid_encoding?
+ return str.scrub('?') if str.respond_to(:scrub)
+ str.chars.collect {|c| c.valid_encoding? ? c : '_' }.join
+ end
+
end