Method: JSONRPC2::HTML.format_result

Defined in:
lib/jsonrpc2/html.rb

.format_result(result) ⇒ Object

Format JSON result



170
171
172
173
174
175
176
177
# File 'lib/jsonrpc2/html.rb', line 170

def format_result(result)
  CGI.escapeHTML(JSON.pretty_unparse(JSON.parse(result))).gsub(%r<("|&quot;)https?://[^"]+?("|&quot;)>) do |str|
    url = CGI.unescapeHTML(str)[1...-1]
     %Q["<a href="#{CGI.escapeHTML(url)}">#{CGI.escapeHTML(url)}</a>"]
  end
rescue Exception => e
  CGI.escapeHTML(result.to_s)
end