rack-jsonr 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjZlYTIxNWI0MzUwZjhhZjhhODBhOWJjZGY3Y2Y4NzUxNjM0ZWIzYQ==
4
+ ZTEzNzM0ZDBmMDhkYmQ2ZDIzODIxNzZhMWUyYjIzODZkMGFlMGI1Yg==
5
5
  data.tar.gz: !binary |-
6
- MTdjZGE5NDEyYjE5Y2I4NDZmMzE4ZGRlN2YwNTNkM2IwZmVlYmExNg==
6
+ M2VhZTNiNDYzYzcyMzkyOTY2NzE1Yzg3ZjcwZGU2ZDFmMWY2NTdiMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjRiNmZjZGEzZjJkYjFjNDQyNTc3NGM4MGJkNzcwZmQxZDI2NGM4MzJlMTZi
10
- ODBiMTg4M2IxZDQ0NjY4OTJmZTFkMGRlODBiMjNkNmZjZGViNTU5ODQxNzZl
11
- Mjg5YWVlODMyNmZhZjQ5Y2U0ZTUzMGYwYzE1ZGZmMTliYWUxYTY=
9
+ ZmFiN2IwMmVlYTExNjNlMDAzOTUzODdmMTY1NTNjMDdkOTM1NWU2NTVhMmQ0
10
+ YWI2Mjk0MDNkMjkzN2Y5MzE1NWQzMDRlMGFhMGE4NThmODEzOWRkZTMxOGY1
11
+ N2ZlN2M3Njc1MWUyNDA5MGExYjM5NTMyMmQ1OTAxZTkxMzM5NjU=
12
12
  data.tar.gz: !binary |-
13
- NjM5YTJlMDk1MTFiYWNkMTAxNGVkMmQ2ZjFhOTlkMzc0ODVjNGZiOGQ4MDEw
14
- ZDlkODJmZTc0MzY1OGI0MTQ5MTM3NGJmNDZmYWIyM2VhNTdiNzJiMWIxNDY5
15
- NGVmNzU2NGVjYjlhNDMxMDFlNmFkYmNmNDQxZTczOGJmNDQ0NjE=
13
+ MDFhNTE1MjA1ZjZjNWY0OTQ2NzllNmE5ODgyNzk0ZWI1YTI4ODE2YWQyMmIy
14
+ ZTNmYWE1MTQ0Y2UwOGYyZDUyNDYxNDAyM2ZhYjEwOTM3YTJlYThlOTI4MGY3
15
+ OTc1ODk5YWVjMzg1NzkwNmVlMWM3ZWZhNTk2NzJkMGE4NTBhYmY=
@@ -72,10 +72,15 @@ module Rack
72
72
  # Formats the JSONP padding to include body, headers and http status
73
73
  #
74
74
  def format_jsonp(callback, status, headers, response, x_headers={}, body='')
75
+ content_is_text = headers['Content-Type'].to_s.include?('text/html') ? true : false
75
76
  headers['Content-Type'] = 'application/javascript;charset=utf-8'
76
77
  headers.each {|k,v| x_headers[k] = v if (k =~ /^X-.+/i) }
77
78
  response.each {|v| body << v.to_s }
78
- body = 'null' if body.nil? or body == ''
79
+ if body.nil? or body == ''
80
+ body = 'null'
81
+ elsif content_is_text
82
+ body = body.to_json
83
+ end
79
84
  ["#{callback}(#{body}, #{status}, #{x_headers.to_json})"]
80
85
  end
81
86
 
@@ -1,3 +1,3 @@
1
1
  class Rack::JSONR
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jsonr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark