jerk 0.0.3 → 0.0.4
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.
- data/jerk.gemspec +1 -1
- data/lib/jerk.rb +18 -6
- data/lib/jerk/version.rb +1 -1
- metadata +3 -3
data/jerk.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["corey.atx@gmail.com"]
|
11
11
|
gem.description = %q{Jerk is insensitive, particularly about URL casing.}
|
12
12
|
gem.summary = %q{Jerk is middleware that prevents any uppercase URLs from making it through in the path of a URL.}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "http://github.com/jonesdilworth/jerk"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/jerk.rb
CHANGED
@@ -13,6 +13,19 @@ module Jerk
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def each(&block); end
|
16
|
+
|
17
|
+
def url_without_query_string(env)
|
18
|
+
req = Rack::Request.new(env)
|
19
|
+
req.base_url + req.script_name + req.path_info
|
20
|
+
end
|
21
|
+
|
22
|
+
def downcased_url(env)
|
23
|
+
if env['QUERY_STRING'].empty?
|
24
|
+
url_without_query_string(env).downcase
|
25
|
+
else
|
26
|
+
url_without_query_string(env).downcase + "?#{env['QUERY_STRING']}"
|
27
|
+
end
|
28
|
+
end
|
16
29
|
end
|
17
30
|
|
18
31
|
### DEFAULT
|
@@ -21,11 +34,8 @@ module Jerk
|
|
21
34
|
include Base
|
22
35
|
|
23
36
|
def call(env)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if path[/[A-Z]/]
|
28
|
-
[301, { Location: [path.downcase, query_string].compact.join('?') }, self]
|
37
|
+
if url_without_query_string(env)[/[A-Z]/]
|
38
|
+
[301, { Location: downcased_url(env) }, self]
|
29
39
|
else
|
30
40
|
super
|
31
41
|
end
|
@@ -37,7 +47,9 @@ module Jerk
|
|
37
47
|
include Base
|
38
48
|
|
39
49
|
def call(env)
|
40
|
-
env['
|
50
|
+
env['HOST'].to_s.downcase!
|
51
|
+
env['SCRIPT_NAME'].to_s.downcase!
|
52
|
+
env['PATH_INFO'].to_s.downcase!
|
41
53
|
super
|
42
54
|
end
|
43
55
|
end
|
data/lib/jerk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/jerk.rb
|
44
44
|
- lib/jerk/railtie.rb
|
45
45
|
- lib/jerk/version.rb
|
46
|
-
homepage:
|
46
|
+
homepage: http://github.com/jonesdilworth/jerk
|
47
47
|
licenses: []
|
48
48
|
post_install_message:
|
49
49
|
rdoc_options: []
|