redirect-rails 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redirect/middleware.rb +5 -5
- data/lib/redirect/rails/version.rb +1 -1
- data/lib/redirect/rails.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6690ed059ca2cea75e6303e9a9a0901448a1d65950d8fd2f4cf2bd9fba22217
|
4
|
+
data.tar.gz: a9f26f09c3700e70522ab9d9032cbc76bbe02738e7ff8575d26732c0d7311446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5a76a662e15d69a78a1774714a7aa109c8aa298f09d677646fb1b5f323801f6809809f674a296e5664a77e9cbb8c3ed53d57af49b05425c2aeebd892b155b0
|
7
|
+
data.tar.gz: 06f16613d08a5e0e0232d7d99f4e9768f39dbf07d9a5e28277daa4cdbf4eda992b37035f1d166dfac99de6f862f08535696ada3b9e3b78de4152bc4dd9a2dc94
|
data/lib/redirect/middleware.rb
CHANGED
@@ -8,19 +8,19 @@ module Redirect
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
@request = Rack::Request.new(env)
|
11
|
-
if
|
12
|
-
|
11
|
+
if url = redirect_url(@request.path)
|
12
|
+
redirect_to(url)
|
13
13
|
else
|
14
14
|
@app.call(env)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def redirect_url(request_path)
|
19
19
|
return unless Redirect::Rails.paths
|
20
20
|
|
21
21
|
Redirect::Rails.paths.map do |path, redirect_path|
|
22
|
-
return
|
23
|
-
end
|
22
|
+
return ERB.new(redirect_path).result(binding) if Regexp.new(path).match(request_path)
|
23
|
+
end.first
|
24
24
|
end
|
25
25
|
|
26
26
|
def redirect_to(uri)
|
data/lib/redirect/rails.rb
CHANGED