sinatra-cors 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/sinatra/cors.rb +12 -1
  3. metadata +4 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b4abf15998834b3658a83b182a1990ac6725a49c
4
- data.tar.gz: 37d772351b207fd7eeae32c5b9b214d30eb0d57d
2
+ SHA256:
3
+ metadata.gz: 99b095a00fa82a4c2cdfe85bdb60179e5869cd1937cffbe109d699547be45b57
4
+ data.tar.gz: d150dc04b51d2af46cf5d45a8c97a2ef1502c75f79b3b209c50375416ad2cc5b
5
5
  SHA512:
6
- metadata.gz: ef81f81eba3dd4a95e15104d8be02ab96da6737ac1bf7f61f828c318aa860765ed9909d54bd938999e2c365b508ecb49d1154b5e60026f0180b3a201022212da
7
- data.tar.gz: 159ba3267236562a09ca848e66bd0eacbee6050ba9d2f25416941d2fe5a3a5c016331cd658d8772362ffa6b25dec1ee2c95c1f8fdad632eba08f555c82356d16
6
+ metadata.gz: 6e0ac7acb9160da93efa2e7d354fa3660af188de53279c964e605654d9750e51270c6c5f1febf7d083c126e1d1ae502ffb6d86be8685321dd580eaa340091e14
7
+ data.tar.gz: df317fc37d8ac9ead35addd46ece5ef59ca3261fc61078e0b10ad74b0cf784644f71030cf058d6314f02e8efe8c747e3176439e92ac3e4a2a748cb6ff5cbbe64
@@ -55,7 +55,18 @@ module Sinatra
55
55
  end
56
56
 
57
57
  def origin_is_allowed?
58
- settings.allow_origin == "*" || settings.allow_origin.downcase.split.include?(request.env["HTTP_ORIGIN"])
58
+ request_origin = request.env["HTTP_ORIGIN"]
59
+
60
+ settings.allow_origin == "*" || [settings.allow_origin]
61
+ .flatten
62
+ .flat_map { |origin| origin.is_a?(String) ? origin.downcase.split : origin }
63
+ .any? do |origin|
64
+ if origin.is_a?(Regexp)
65
+ origin.match?(request_origin)
66
+ else
67
+ origin.eql?(request_origin)
68
+ end
69
+ end
59
70
  end
60
71
 
61
72
  def allowed_methods
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Desrosiers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'This Sinatra plugin supports the full CORS spec including automatic
14
14
  support for CORS preflight (OPTIONS) requests. It uses CORS security best practices. The
15
15
  plugin logs to the default logger to guide you in setting things up properly. It
16
16
  will tell you why a CORS request failed and tell you how to fix it.
17
17
 
18
- '
18
+ '
19
19
  email: jdesrosi@gmail.com
20
20
  executables: []
21
21
  extensions: []
@@ -41,8 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubyforge_project:
45
- rubygems_version: 2.6.13
44
+ rubygems_version: 3.1.2
46
45
  signing_key:
47
46
  specification_version: 4
48
47
  summary: CORS support for Sinatra applications