redirect-rails 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/config/redirect.yml +2 -2
- data/lib/redirect/middleware.rb +9 -9
- data/lib/redirect/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c66620968de2d42cd6e33412b00efb687f4923aaaffd900228ac985bdb333f3e
|
4
|
+
data.tar.gz: 104b84668431748b12106c7b2e9c21adbc003da3d835e98d5071ed7fa8c96156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75e6682ea244c26e8a2f49e8b62205291ee38943ef05abc960a77bc8c3158edc581f01840ecd25a4637a06b0c0c1ada8cef868daf2a5a3d7b191f7e0270779ae
|
7
|
+
data.tar.gz: 18800ad819165a411eaf99bef5508e23e1cda4b6f097b6de49f127317d41ae89d4efbba2f8c4afad083a0204177f0870db8dfeb81e6edc001215991216c95f08
|
data/README.md
CHANGED
@@ -19,9 +19,21 @@ $ bin/rails redirect:install
|
|
19
19
|
|
20
20
|
List the correspondence of the paths you want to redirect in config/redirect.yml."
|
21
21
|
|
22
|
+
## paths
|
23
|
+
|
24
|
+
In the `config/redirect.yml` file, you can write redirect settings as follows.
|
25
|
+
|
26
|
+
```
|
27
|
+
paths:
|
28
|
+
/regexp/([^/]+): /redirected/regexp/<%= $1 %>
|
29
|
+
/static/failuer: /static/true
|
30
|
+
```
|
31
|
+
|
22
32
|
## Contributing
|
23
33
|
|
24
|
-
|
34
|
+
- No test code yet. Pull requests are welcome.
|
35
|
+
|
36
|
+
-Bug reports and pull requests are welcome on GitHub at https://github.com/slidict/redirect-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/slidict/redirect-rails/blob/main/CODE_OF_CONDUCT.md).
|
25
37
|
|
26
38
|
## License
|
27
39
|
|
data/config/redirect.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
paths:
|
2
|
-
# /
|
3
|
-
# /
|
2
|
+
# /regexp/([^/]+): /redirected/regexp/<%= $1 %>
|
3
|
+
# /static/failuer: /static/true
|
data/lib/redirect/middleware.rb
CHANGED
@@ -16,19 +16,19 @@ module Redirect
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def match?(request_path)
|
19
|
+
return if Redirect::Rails.paths
|
20
|
+
|
19
21
|
Redirect::Rails.paths.map do |path, redirect_path|
|
20
|
-
if Regexp.new(path).match(request_path)
|
21
|
-
|
22
|
-
end
|
23
|
-
end if Redirect::Rails.paths
|
24
|
-
return nil
|
22
|
+
return redirect_to(ERB.new(redirect_path).result(binding)) if Regexp.new(path).match(request_path)
|
23
|
+
end
|
25
24
|
end
|
26
25
|
|
27
26
|
def redirect_to(uri)
|
28
|
-
headers = {
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
headers = { "Location": uri,
|
28
|
+
"Content-Type": @request["Content-Type"],
|
29
|
+
"Pragma": "no-cache",
|
30
|
+
"Cache-Control": "no-cache; max-age=0"
|
31
|
+
}
|
32
32
|
[302, headers, [redirect_message(uri)]]
|
33
33
|
end
|
34
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redirect-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
72
|
+
rubygems_version: 3.5.7
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Provide a routing table dedicated to redirect in rails.
|