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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f0ecdb8725a6803349e51b90dc85872681c6162
4
- data.tar.gz: 09c706a18e0cfb180d606472bf9a8f459fa9c8f7
3
+ metadata.gz: 215153cc8a15d43896a220800cbd869135dcc05d
4
+ data.tar.gz: e0f6533003427b3167d444b64551343c95dbd1fe
5
5
  SHA512:
6
- metadata.gz: 56b20be331349761df60822bf4232c19baaa3a4b20a8364fb78a650a09bbb6f928210cc265b436c2f4ade9cebb110d78ca33da96aa9173265e114f7c66ae941a
7
- data.tar.gz: 0dcb8ece149ed00d4f82c66f3b4f9de940337377006b7fbc7716011b6a050f384ba59354c7091d80a7c5b77f6ac319031ab83f374a8e4ff61d054286d221bbf7
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
- ### go_to_path_or
66
+ ### go_to_path
67
67
 
68
68
  Finally use the `go_to` parameter.
69
69
 
70
- You must pass in a fallback path.
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 go_to_path_or(root_path)
76
+ redirect_to(go_to_path || root_path)
77
77
  end
78
78
  end
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module GoToParam
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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, go_to_value
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: go_to_value }.merge(other_params)
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 go_to_path_or(path)
24
+ def go_to_path
25
25
  # Avoid phishing redirects.
26
- if go_to_value.to_s.start_with?("/")
27
- go_to_value
26
+ if raw_go_to_param_value.to_s.start_with?("/")
27
+ raw_go_to_param_value
28
28
  else
29
- path
29
+ nil
30
30
  end
31
31
  end
32
32
 
33
33
  private
34
34
 
35
- def go_to_value
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 "#go_to_path_or" do
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.go_to_path_or("/default").should == "/example"
69
+ controller.go_to_path.should == "/example"
70
70
  end
71
71
 
72
- it "falls back to the passed-in value without a parameter value" do
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.go_to_path_or("/default").should == "/default"
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.1
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/go_to_spec.rb
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/go_to_spec.rb
95
+ - spec/go_to_param_spec.rb
96
96
  has_rdoc: