rack-its-spelled-referrer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +28 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/lib/rack/its/spelled/referrer.rb +33 -0
- data/lib/rack/its/spelled/referrer/version.rb +9 -0
- data/rack-its-spelled-referrer.gemspec +28 -0
- data/spec/its_spelled_referrer_spec.rb +28 -0
- data/spec/spec_helper.rb +89 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2725ca84fc9bc94076d4539633fcb1e3da14ca13
|
4
|
+
data.tar.gz: 9f7c7646da3bf7506e9077906de935c8cf8e58d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb0a96592618cbdfd98eb4e406c4aa93a06429879c44024efc6105169703bafd11938b8f31de8b065f6adf48e1bb30602d619c6afc3c62caf43f4d6bba9926ba
|
7
|
+
data.tar.gz: 53d0b2e50808b8b9a3b0a4ab2e1710598b7a4207290706e8321d4183d8cc353ee8ddd17721529aae90dc0e91fb10abb099dc49f78336e4f0b82da2b971e4e30b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
CC0 1.0 Universal (CC0 1.0)
|
2
|
+
Public Domain Dedication
|
3
|
+
|
4
|
+
This is a human-readable summary of the Legal Code available at:
|
5
|
+
http://creativecommons.org/publicdomain/zero/1.0/legalcode
|
6
|
+
|
7
|
+
# No Copyright
|
8
|
+
|
9
|
+
The person who associated a work with this deed has dedicated the work to the
|
10
|
+
public domain by waiving all of his or her rights to the work worldwide under
|
11
|
+
copyright law, including all related and neighboring rights, to the extent
|
12
|
+
allowed by law.
|
13
|
+
|
14
|
+
You can copy, modify, distribute and perform the work, even for commercial
|
15
|
+
purposes, all without asking permission. See Other Information below.
|
16
|
+
|
17
|
+
# Other Information
|
18
|
+
|
19
|
+
In no way are the patent or trademark rights of any person affected by CC0, nor
|
20
|
+
are the rights that other persons may have in the work or in how the work is
|
21
|
+
used, such as publicity or privacy rights.
|
22
|
+
|
23
|
+
Unless expressly stated otherwise, the person who associated a work with this
|
24
|
+
deed makes no warranties about the work, and disclaims liability for all uses of
|
25
|
+
the work, to the fullest extent permitted by applicable law.
|
26
|
+
|
27
|
+
When using or citing the work, you should not imply endorsement by the author
|
28
|
+
or the affirmer.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Rack::Its::Spelled::Referrer
|
2
|
+
|
3
|
+
Copies the `referer` header to `referrer`.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rack-its-spelled-referrer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
In the `config.ru` of your Rack application:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'rack/its/spelled/referrer'
|
23
|
+
use Rack::Its::Spelled::Referrer
|
24
|
+
```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/bkerley/rack-its-spelled-referrer/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "rack/its/spelled/referrer/version"
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
module Its
|
5
|
+
module Spelled
|
6
|
+
class Referrer
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
referer = find_referer env
|
13
|
+
|
14
|
+
return @app.call env unless referer
|
15
|
+
|
16
|
+
fix_spelling env, referer
|
17
|
+
|
18
|
+
return @app.call env
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def find_referer(env)
|
24
|
+
return env['HTTP_REFERER']
|
25
|
+
end
|
26
|
+
|
27
|
+
def fix_spelling(env, referer)
|
28
|
+
env['HTTP_REFERRER'] = referer
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rack/its/spelled/referrer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rack-its-spelled-referrer"
|
8
|
+
spec.version = Rack::Its::Spelled::Referrer::VERSION
|
9
|
+
spec.authors = ["Bryce Kerley"]
|
10
|
+
spec.email = ["bkerley@brycekerley.net"]
|
11
|
+
spec.summary = %q{Fixes a misspelling in HTTP.}
|
12
|
+
spec.description = %q{Copies the `referer` header to `referrer`.}
|
13
|
+
spec.homepage = "https://github.com/bkerley/rack-its-spelled-referrer"
|
14
|
+
spec.license = "CC0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
|
25
|
+
spec.add_dependency "rack", "~> 1.0"
|
26
|
+
|
27
|
+
spec.required_ruby_version = '>= 1.9.3'
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rack/mock'
|
2
|
+
require 'rack/its/spelled/referrer'
|
3
|
+
|
4
|
+
describe Rack::Its::Spelled::Referrer do
|
5
|
+
let(:app) do
|
6
|
+
spy('app', call: [200, {}, ['ok']])
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:url){ 'http://example.invalid' }
|
10
|
+
|
11
|
+
let(:middleware){ described_class.new app }
|
12
|
+
|
13
|
+
subject(:request) do
|
14
|
+
Rack::MockRequest.new middleware
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'lints without issue' do
|
18
|
+
resp = nil
|
19
|
+
expect{ resp = subject.get url, lint: true }.to_not raise_error
|
20
|
+
expect(resp.errors).to be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'replaces the Referer header with Referrer' do
|
24
|
+
resp = subject.get(url, lint: true, 'HTTP_REFERER' => url)
|
25
|
+
expect(resp.errors).to be_empty
|
26
|
+
expect(app).to have_received(:call).with(hash_including('HTTP_REFERER' => url, 'HTTP_REFERRER' => url))
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# The settings below are suggested to provide a good initial experience
|
42
|
+
# with RSpec, but feel free to customize to your heart's content.
|
43
|
+
=begin
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# be too noisy due to issues in dependencies.
|
60
|
+
config.warnings = true
|
61
|
+
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print the 10 slowest examples and example groups at the
|
73
|
+
# end of the spec run, to help surface which specs are running
|
74
|
+
# particularly slow.
|
75
|
+
config.profile_examples = 10
|
76
|
+
|
77
|
+
# Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# order dependency and want to debug it, you can fix the order by providing
|
79
|
+
# the seed, which is printed after each run.
|
80
|
+
# --seed 1234
|
81
|
+
config.order = :random
|
82
|
+
|
83
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
+
# test failures related to randomization by passing the same `--seed` value
|
86
|
+
# as the one that triggered the failure.
|
87
|
+
Kernel.srand config.seed
|
88
|
+
=end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-its-spelled-referrer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryce Kerley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
description: Copies the `referer` header to `referrer`.
|
70
|
+
email:
|
71
|
+
- bkerley@brycekerley.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/rack/its/spelled/referrer.rb
|
84
|
+
- lib/rack/its/spelled/referrer/version.rb
|
85
|
+
- rack-its-spelled-referrer.gemspec
|
86
|
+
- spec/its_spelled_referrer_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
homepage: https://github.com/bkerley/rack-its-spelled-referrer
|
89
|
+
licenses:
|
90
|
+
- CC0
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.9.3
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Fixes a misspelling in HTTP.
|
112
|
+
test_files:
|
113
|
+
- spec/its_spelled_referrer_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
has_rdoc:
|