rack-cors 2.0.0 → 2.0.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.

Potentially problematic release.


This version of rack-cors might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6edbdc45ea6ee992d901d2247a525bbc9b5073ad30cbde1ea8de9cf3addb87a2
4
- data.tar.gz: 164c53dabece23422babf95ac1ecf108f3e0f44cf8101781ea30df290ff7ddc7
3
+ metadata.gz: f47b5b2ba34721795ddb1c65e70e989134655e7f47116dd977edee702a79f41f
4
+ data.tar.gz: 7c03dc701b00b7418ab4d733872fccc3522392f0f85014b8ca25045767d866a9
5
5
  SHA512:
6
- metadata.gz: 90c845fbb2c197c33dce3902684dc284ea2ad888d2d57d3a62454f4fd6fa3612a2c23d3a1d97394929a44e0dfdff4513ca533d6ff820975f020c482adda35b08
7
- data.tar.gz: da1506992c2f78e26c9f045b996843d3ce2af0bcce85425c3af38c53fdd2f240b064e5753a8e86e80b30563b63537b46b1528b05f1d98625e1b65225e5d892dc
6
+ metadata.gz: d5a94b8f282fd5367e125f4b49e18ce5fb1c07581d89b2d50dc8cf4eb70e8404d97c78a6ccaf90f1e41f0f220bb09ff9dd07a4677559935cc35256674e6c512d
7
+ data.tar.gz: bee187e2dc53281d8b454df32b6a8fd50e05b66de4f25649d74f176abf29d52eb4cee5a2b2e602e087c5f5805b6dd55ab86a9e0692d3d82c5538e0c30e3c020b
@@ -0,0 +1,39 @@
1
+ name: ci
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby:
13
+ - "2.3"
14
+ - "2.4"
15
+ - "2.5"
16
+ - "2.6"
17
+ - "2.7"
18
+ - "3.0"
19
+ - "3.1"
20
+ - "3.2"
21
+ - truffleruby-head
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ bundler-cache: true
29
+ - run: bundle exec rake test
30
+
31
+ rubocop:
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v3
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: 3.2.1
38
+ bundler-cache: true
39
+ - run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  ---
2
-
3
2
  AllCops:
4
3
  Exclude:
5
- - 'examples/**/*'
4
+ - "examples/**/*"
5
+ - "vendor/**/*"
6
6
 
7
7
  # Disables
8
8
  Layout/LineLength:
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## 2.0.0 - 2022-09-11
4
+ ## 2.0.1 - 2023-02-17
5
+ ### Changed
6
+ - Use Rack::Utils::HeaderHash when Rack 2.x is detected
7
+
8
+ ## 2.0.0 - 2023-02-14
5
9
  ### Changed
6
10
  - Refactored codebase
7
11
  - Support declaring custom protocols in origin
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rack CORS Middleware [![Build Status](https://travis-ci.org/cyu/rack-cors.svg?branch=master)](https://travis-ci.org/cyu/rack-cors)
1
+ # Rack CORS Middleware [![Build Status](https://github.com/cyu/rack-cors/actions/workflows/ci.yaml/badge.svg)](https://github.com/cyu/rack-cors/actions)
2
2
 
3
3
  `Rack::Cors` provides support for Cross-Origin Resource Sharing (CORS) for Rack compatible web applications.
4
4
 
@@ -66,7 +66,7 @@ module Rack
66
66
  'access-control-max-age' => max_age.to_s
67
67
  }
68
68
  h['access-control-allow-credentials'] = 'true' if credentials
69
- h
69
+ header_proc.call(h)
70
70
  end
71
71
 
72
72
  protected
@@ -127,6 +127,16 @@ module Rack
127
127
  raise TypeError, path
128
128
  end
129
129
  end
130
+
131
+ def header_proc
132
+ @header_proc ||= begin
133
+ if defined?(Rack::Headers)
134
+ ->(h) { h }
135
+ else
136
+ ->(h) { Rack::Utils::HeaderHash.new(h) }
137
+ end
138
+ end
139
+ end
130
140
  end
131
141
  end
132
142
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Cors
5
- VERSION = '2.0.0'
5
+ VERSION = '2.0.1'
6
6
  end
7
7
  end
data/rack-cors.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'minitest', '~> 5.11.0'
25
25
  spec.add_development_dependency 'mocha', '~> 1.6.0'
26
26
  spec.add_development_dependency 'pry', '~> 0.12'
27
- spec.add_development_dependency 'rack-test', '~> 1.1.0'
27
+ spec.add_development_dependency 'rack-test', '>= 1.1.0'
28
28
  spec.add_development_dependency 'rake', '~> 12.3.0'
29
29
  spec.add_development_dependency 'rubocop', '~> 0.80.1'
30
30
  end
@@ -70,7 +70,7 @@ describe Rack::Cors do
70
70
  use FakeProxy if options[:proxy]
71
71
  map('/') do
72
72
  run(lambda do |_env|
73
- [200, { 'Content-Type' => 'text/html' }, ['success']]
73
+ [200, { 'content-type' => 'text/html' }, ['success']]
74
74
  end)
75
75
  end
76
76
  end
@@ -428,7 +428,7 @@ describe Rack::Cors do
428
428
  @app ||= Rack::Builder.new do
429
429
  use Rack::Cors
430
430
  use Rack::Lint
431
- run ->(_env) { [200, { 'Content-Type' => 'text/html' }, ['hello']] }
431
+ run ->(_env) { [200, { 'content-type' => 'text/html' }, ['hello']] }
432
432
  end
433
433
  end
434
434
 
@@ -474,7 +474,7 @@ describe Rack::Cors do
474
474
  end
475
475
  end
476
476
  map('/') do
477
- run ->(_env) { [200, { 'Content-Type' => 'text/html' }, ['hello']] }
477
+ run ->(_env) { [200, { 'content-type' => 'text/html' }, ['hello']] }
478
478
  end
479
479
  end
480
480
  end
@@ -495,7 +495,7 @@ describe Rack::Cors do
495
495
  end
496
496
  end
497
497
  map('/') do
498
- run ->(_env) { [200, { 'Content-Type' => 'text/html' }, ['hello']] }
498
+ run ->(_env) { [200, { 'content-type' => 'text/html' }, ['hello']] }
499
499
  end
500
500
  end
501
501
  end
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: 2.0.0
4
+ version: 2.0.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: 2023-02-14 00:00:00.000000000 Z
11
+ date: 2023-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -90,14 +90,14 @@ dependencies:
90
90
  name: rack-test
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: 1.1.0
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: 1.1.0
103
103
  - !ruby/object:Gem::Dependency
@@ -136,8 +136,8 @@ executables: []
136
136
  extensions: []
137
137
  extra_rdoc_files: []
138
138
  files:
139
+ - ".github/workflows/ci.yaml"
139
140
  - ".rubocop.yml"
140
- - ".travis.yml"
141
141
  - CHANGELOG.md
142
142
  - Gemfile
143
143
  - LICENSE.txt
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.1.2
184
+ rubygems_version: 3.3.26
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Middleware for enabling Cross-Origin Resource Sharing in Rack apps
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5
7
- - 2.6
8
- - 2.7
9
- - truffleruby-head
10
-
11
- script:
12
- - bundle exec rubocop
13
- - bundle exec rake test