diff --git a/lib/rock_rms/parse_oj.rb b/lib/rock_rms/parse_oj.rb index 45c7657..6fd361a 100644 --- a/lib/rock_rms/parse_oj.rb +++ b/lib/rock_rms/parse_oj.rb @@ -5,6 +5,8 @@ class ParseOj < Faraday::Middleware def on_complete(env) if empty_body?(env[:body].strip) env[:body] = nil + elsif html_body?(env[:body]) + env[:body] = env[:body] else env[:body] = Oj.load(env[:body], mode: :compat) end @@ -12,6 +14,10 @@ def on_complete(env) private + def html_body?(body) + body.start_with?('') + end + def empty_body?(body) body.empty? && body == '' end