rack-canonical-host 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/rack/canonical_host/request.rb +37 -0
- data/lib/rack/canonical_host/version.rb +1 -1
- data/lib/rack/canonical_host.rb +5 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8352b4f1e9965403537863274605aa874e659dd21601d1bd30e75530c9aa3c26
|
4
|
+
data.tar.gz: bc8e09feaf6ef9fc84faf977b9e6a86efb9ee3af1e3efa5b3e03437bbde0c4a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a27ba70e319608c1c0732a4cfb03ecd8ac972f49d43ff10d27d05342282dccd6f392d4601e975d7228ef895a3e6f63b206476f48c8cced5828b1cf35ed73d5f1
|
7
|
+
data.tar.gz: a49b560f4628d5f6e60dac7baa7452adee5d852b8a36532536bd95b59ddeda4d19022d496461f97a02cad2f1a87d04241c63e187d56ff69ebf00c452b72dc53f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.0 (2024-03-15)
|
4
|
+
|
5
|
+
* Respond to invalid request URL with 400 ([Gareth Jones][G-Rath])
|
6
|
+
* Drop support for Rack 1.5 ([Tyler Hunt][tylerhunt])
|
7
|
+
|
3
8
|
## 1.2.0 (2023-04-14)
|
4
9
|
|
5
10
|
* Add support for Rack 3.0 ([Vinny Diehl][vinnydiehl])
|
@@ -94,3 +99,4 @@
|
|
94
99
|
[zoso10]: https://github.com/zoso10
|
95
100
|
[olleolleolle]: https://github.com/olleolleolle
|
96
101
|
[vinnydiehl]: https://github.com/vinnydiehl
|
102
|
+
[G-Rath]: https://github.com/G-Rath
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class CanonicalHost
|
6
|
+
class Request
|
7
|
+
BAD_REQUEST = <<-HTML.gsub(/^\s+/, '')
|
8
|
+
<!DOCTYPE html>
|
9
|
+
<html lang="en-US">
|
10
|
+
<head><title>400 Bad Request</title></head>
|
11
|
+
<body>
|
12
|
+
<h1>Bad Request</h1>
|
13
|
+
</body>
|
14
|
+
</html>
|
15
|
+
HTML
|
16
|
+
|
17
|
+
def initialize(env)
|
18
|
+
self.env = env
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?
|
22
|
+
Addressable::URI.parse(Rack::Request.new(env).url)
|
23
|
+
true
|
24
|
+
rescue Addressable::URI::InvalidURIError
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def bad_request_response
|
29
|
+
[400, { 'content-type' => 'text/html' }, [BAD_REQUEST]]
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
attr_accessor :env
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rack/canonical_host.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'rack/canonical_host/redirect'
|
3
|
+
require 'rack/canonical_host/request'
|
3
4
|
require 'rack/canonical_host/version'
|
4
5
|
|
5
6
|
module Rack
|
@@ -12,6 +13,10 @@ module Rack
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(env)
|
16
|
+
request = Request.new(env)
|
17
|
+
|
18
|
+
return request.bad_request_response unless request.valid?
|
19
|
+
|
15
20
|
host = evaluate_host(env)
|
16
21
|
redirect = Redirect.new(env, host, options)
|
17
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-canonical-host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1'
|
39
|
+
version: '1.6'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '4'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1'
|
49
|
+
version: '1.6'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '4'
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/rack-canonical-host.rb
|
105
105
|
- lib/rack/canonical_host.rb
|
106
106
|
- lib/rack/canonical_host/redirect.rb
|
107
|
+
- lib/rack/canonical_host/request.rb
|
107
108
|
- lib/rack/canonical_host/version.rb
|
108
109
|
homepage: https://github.com/tylerhunt/rack-canonical-host
|
109
110
|
licenses:
|