jsonatra 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/lib/jsonatra/version.rb +1 -1
- data/lib/jsonatra.rb +9 -9
- data/test/jsonatra_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b70ca65553dfbc643e303901211b596bd20fde62
|
4
|
+
data.tar.gz: 2ab473350a070324ea3cf5d910504f1e6a9d46bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 155a4953fce08b0e2fa2258c35bc8b1b0645af5dae81b4ddff2b64e43d01d77737f447f5420b31bb35ba1a8151231bd470e9de824ad40aa4d1eeb6ab4e023ac2
|
7
|
+
data.tar.gz: 56252f3bc023931b56796287934597611d80032744e93fe79d743c1344fdc4f65d5fb1685edede05324cc2173f8c9e4186bfd5bd982c9f491ab2705999cded68
|
data/.travis.yml
CHANGED
data/lib/jsonatra/version.rb
CHANGED
data/lib/jsonatra.rb
CHANGED
@@ -52,15 +52,6 @@ module Jsonatra
|
|
52
52
|
|
53
53
|
before do
|
54
54
|
|
55
|
-
# default to Content-Type to JSON, or javascript if request is JSONP
|
56
|
-
#
|
57
|
-
content_type :json
|
58
|
-
unless params[:callback].nil? or params[:callback] == ''
|
59
|
-
halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
|
60
|
-
response.jsonp_callback = params[:callback]
|
61
|
-
content_type :js
|
62
|
-
end
|
63
|
-
|
64
55
|
# grok access control headers
|
65
56
|
#
|
66
57
|
achs = begin
|
@@ -79,6 +70,15 @@ module Jsonatra
|
|
79
70
|
#
|
80
71
|
achs.each {|k,v| headers[k] = v}
|
81
72
|
|
73
|
+
# default to Content-Type to JSON, or javascript if request is JSONP
|
74
|
+
#
|
75
|
+
content_type :json
|
76
|
+
unless params[:callback].nil? or params[:callback] == ''
|
77
|
+
halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
|
78
|
+
response.jsonp_callback = params[:callback]
|
79
|
+
content_type :js
|
80
|
+
end
|
81
|
+
|
82
82
|
end
|
83
83
|
|
84
84
|
after do
|
data/test/jsonatra_spec.rb
CHANGED
@@ -108,6 +108,19 @@ describe Jsonatra::Base do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
it 'responds with CORS headers even when content-type is mismatched' do
|
112
|
+
params = {foo: 'bar'}.to_json
|
113
|
+
[:get, :post].each do |meth|
|
114
|
+
__send__ meth, '/', params, { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
115
|
+
last_response.headers.keys.must_include 'Access-Control-Allow-Origin'
|
116
|
+
last_response.headers['Access-Control-Allow-Origin'].must_equal '*'
|
117
|
+
last_response.headers.keys.must_include 'Access-Control-Allow-Headers'
|
118
|
+
last_response.headers['Access-Control-Allow-Headers'].must_equal 'Accept, Authorization, Content-Type, Origin'
|
119
|
+
last_response.headers.keys.must_include 'Access-Control-Allow-Methods'
|
120
|
+
last_response.headers['Access-Control-Allow-Methods'].must_equal 'GET, POST'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
111
124
|
end
|
112
125
|
|
113
126
|
describe 'access_control_headers' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|