go_to_param 0.0.1 → 0.0.2
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/README.md +3 -3
- data/lib/go_to_param/version.rb +1 -1
- data/lib/go_to_param.rb +7 -7
- data/spec/{go_to_spec.rb → go_to_param_spec.rb} +4 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 215153cc8a15d43896a220800cbd869135dcc05d
|
4
|
+
data.tar.gz: e0f6533003427b3167d444b64551343c95dbd1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d175624844e430d3a24c0221958677141e40503f8902f920cac9179e32f2effcee2e4a6a6ac65cc2379d64323e3bdb6d89815dda9ea61d47baf5f9f11163fca
|
7
|
+
data.tar.gz: f882c0c017e88fe25cba15d49b962e0cdd6f90b0120a43cad6b74afc916d6c63f2d4dc4763c1b7ab95c898b337a39a6b98d39f4ba2b5e0a3c8a20793d6cf7dbc
|
data/README.md
CHANGED
@@ -63,17 +63,17 @@ You can pass in additional parameters for the given path:
|
|
63
63
|
<%= link_to("Reset password", password_reset_path(go_to_param(email: @email))) %>
|
64
64
|
```
|
65
65
|
|
66
|
-
###
|
66
|
+
### go_to_path
|
67
67
|
|
68
68
|
Finally use the `go_to` parameter.
|
69
69
|
|
70
|
-
You
|
70
|
+
You probably want to provide a fallback path:
|
71
71
|
|
72
72
|
``` ruby
|
73
73
|
class SessionsController < ActionController::Base
|
74
74
|
def create
|
75
75
|
if logged_in?
|
76
|
-
redirect_to
|
76
|
+
redirect_to(go_to_path || root_path)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/go_to_param/version.rb
CHANGED
data/lib/go_to_param.rb
CHANGED
@@ -6,11 +6,11 @@ module GoToParam
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def hidden_go_to_tag
|
9
|
-
view_context.hidden_field_tag :go_to,
|
9
|
+
view_context.hidden_field_tag :go_to, go_to_path
|
10
10
|
end
|
11
11
|
|
12
12
|
def go_to_param(other_params = {})
|
13
|
-
{ go_to:
|
13
|
+
{ go_to: go_to_path }.merge(other_params)
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_go_to_param
|
@@ -21,18 +21,18 @@ module GoToParam
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def go_to_path
|
25
25
|
# Avoid phishing redirects.
|
26
|
-
if
|
27
|
-
|
26
|
+
if raw_go_to_param_value.to_s.start_with?("/")
|
27
|
+
raw_go_to_param_value
|
28
28
|
else
|
29
|
-
|
29
|
+
nil
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def
|
35
|
+
def go_to_param_value
|
36
36
|
params[:go_to]
|
37
37
|
end
|
38
38
|
end
|
@@ -63,21 +63,15 @@ describe GoToParam do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe "#
|
66
|
+
describe "#go_to_path" do
|
67
67
|
it "is the go_to parameter value" do
|
68
68
|
controller.params = { go_to: "/example", id: "1" }
|
69
|
-
controller.
|
69
|
+
controller.go_to_path.should == "/example"
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
73
|
-
controller = FakeController.new
|
74
|
-
controller.params = { id: "1" }
|
75
|
-
controller.go_to_path_or("/default").should == "/default"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "only allows relative paths" do
|
72
|
+
it "is nil if the parameter value is not a relative path" do
|
79
73
|
controller.params = { go_to: "http://evil.com", id: "1" }
|
80
|
-
controller.
|
74
|
+
controller.go_to_path.should be_nil
|
81
75
|
end
|
82
76
|
end
|
83
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_to_param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik N
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- go_to_param.gemspec
|
67
67
|
- lib/go_to_param.rb
|
68
68
|
- lib/go_to_param/version.rb
|
69
|
-
- spec/
|
69
|
+
- spec/go_to_param_spec.rb
|
70
70
|
homepage: ''
|
71
71
|
licenses:
|
72
72
|
- MIT
|
@@ -92,5 +92,5 @@ signing_key:
|
|
92
92
|
specification_version: 4
|
93
93
|
summary: Rails "go_to" redirection param utilities.
|
94
94
|
test_files:
|
95
|
-
- spec/
|
95
|
+
- spec/go_to_param_spec.rb
|
96
96
|
has_rdoc:
|