rack-cors 1.1.0 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd2274b31c1fff80172aeae55b715d3adcc39c32665cf3fa85707fcedc2e7d02
4
- data.tar.gz: 87790b6bbd36a084ea24af33694650c3a38ded6d85d43321edeee3f53b23c8c5
3
+ metadata.gz: 8f879bc8ea95eac0ca9360c3a553084961d02944255f6ad380b64e855653b8b6
4
+ data.tar.gz: bd9478603340a1785324ab4f1db9517a8943fdcc1be13193e4d6b83b184fa032
5
5
  SHA512:
6
- metadata.gz: 74899fd0bca2abc5498ea3172f9b7909f1d45f1c1f029c23e48f868533d7a71827574c307bc48a74c66e17a3046d387d48cf07a7de868e4dcf2ce057f894b2ec
7
- data.tar.gz: 918f644a445522eb52dd065252e1fee13917225f40f44e1cfbe40a73864d60ca993db08228edb78bda5b920b84c371e417dc3965752fbda43bb7eb5e67553fa3
6
+ metadata.gz: 12d13e99acef13b159595487b3c0198bc1a355371bdb149241d11e1d0715148e0749085d0f0c362d4defdec2e325b416b1e93aeb28be2d421516d4db8185fdac
7
+ data.tar.gz: a1f373194a95094f337c545e7751eac2c4d8500dfd607088a88e55774b755fa0ec659710319a2f7997e579231b7de806e63f2ce4a1639cdb732eed5bcbb743b9
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 1.1.1 - 2019-12-29
5
+ ### Changed
6
+ - Allow /<resource>/* to match /<resource>/ and /<resource> paths
7
+
4
8
  ## 1.1.0 - 2019-11-19
5
9
  ### Changed
6
10
  - Use Rack::Utils.escape_path instead of Rack::Utils.escape
@@ -447,8 +447,10 @@ module Rack
447
447
  if path.respond_to? :to_str
448
448
  special_chars = %w{. + ( )}
449
449
  pattern =
450
- path.to_str.gsub(/((:\w+)|[\*#{special_chars.join}])/) do |match|
450
+ path.to_str.gsub(/((:\w+)|\/\*|[\*#{special_chars.join}])/) do |match|
451
451
  case match
452
+ when "/*"
453
+ "\\/?(.*?)"
452
454
  when "*"
453
455
  "(.*?)"
454
456
  when *special_chars
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Cors
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -341,13 +341,25 @@ describe Rack::Cors do
341
341
  last_response.must_render_cors_success
342
342
  end
343
343
 
344
- it 'should * origin should allow any origin' do
344
+ it "should allow '*' origins to allow any origin" do
345
345
  preflight_request('http://locohost:3000', '/public')
346
346
  last_response.must_render_cors_success
347
347
  last_response.headers['Access-Control-Allow-Origin'].must_equal '*'
348
348
  end
349
349
 
350
- it 'should * origin should allow any origin, and set * if no credentials required' do
350
+ it "should allow '/<path>/' resource if match pattern is /<path>/*" do
351
+ preflight_request('http://localhost:3000', '/wildcard/')
352
+ last_response.must_render_cors_success
353
+ last_response.headers['Access-Control-Allow-Origin'].wont_equal nil
354
+ end
355
+
356
+ it "should allow '/<path>' resource if match pattern is /<path>/*" do
357
+ preflight_request('http://localhost:3000', '/wildcard')
358
+ last_response.must_render_cors_success
359
+ last_response.headers['Access-Control-Allow-Origin'].wont_equal nil
360
+ end
361
+
362
+ it "should allow '*' origin to allow any origin, and set '*' if no credentials required" do
351
363
  preflight_request('http://locohost:3000', '/public_without_credentials')
352
364
  last_response.must_render_cors_success
353
365
  last_response.headers['Access-Control-Allow-Origin'].must_equal '*'
@@ -20,6 +20,7 @@ use Rack::Cors do
20
20
  resource '/conditional', :methods => :get, :if => proc { |env| !!env['HTTP_X_OK'] }
21
21
  resource '/vary_test', :methods => :get, :vary => %w{ Origin Host }
22
22
  resource '/patch_test', :methods => :patch
23
+ resource '/wildcard/*', :methods => :any
23
24
  # resource '/file/at/*',
24
25
  # :methods => [:get, :post, :put, :delete],
25
26
  # :headers => :any,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calvin Yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.0.6
150
+ rubygems_version: 3.0.3
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Middleware for enabling Cross-Origin Resource Sharing in Rack apps