go_to_param 1.0.0 → 1.1.0

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: 6fa16c7fe969b722bbc7f884c7b2f1b24df75bb7
4
- data.tar.gz: 0e7c3acd3d434566ffeb201eb006a43765dad107
3
+ metadata.gz: 19bbfd139f7a3c04cae82b201603264929282a8d
4
+ data.tar.gz: 664fd95648b290ccbdc9f5084d3ea6ed3ea54ee6
5
5
  SHA512:
6
- metadata.gz: bfccf03b703ea760d1b8ae8a81cd238052248b18f70e3044d76856577edbdc40f304602178d4716774427fde0579d0a19062e7bf1c401509fa401d85978e1ee0
7
- data.tar.gz: 45575857ba7c020275d9f1384264b13a4c4892afaefc30864babf7b206197c2f6362b303bf872b8e3b129036d91a0edb546b8244d0a0c45114670371c5c1d26c
6
+ metadata.gz: fa371354b00c217ee6fa0b43d3b8d1e6b91fc2e6d2e88ac85cb7044d95ed453e59bb9f6111926fd770b15dfc676cbb1cec8c50bcc3195caccc08de41a0e5d184
7
+ data.tar.gz: 657fb095986d8300e54a473012fe7ff0f6d57f44255fb51c4fc18ac7e053341f216b9a26c5849739abc0903448544500aaa0323e37d8621b6592f60909ab9f85
data/README.md CHANGED
@@ -55,6 +55,8 @@ You can pass additional query parameters to include, which could be suitable if
55
55
 
56
56
  Note that these parameters always become transformed into a query string: if you're using Ruby on Rails, they won't be interpreted through your route definitions.
57
57
 
58
+ You can, however, pass a Rails-style `anchor: "foo"` parameter to set the URL fragment (`/example#foo`).
59
+
58
60
 
59
61
  ### hidden_go_to_tag
60
62
 
data/lib/go_to_param.rb CHANGED
@@ -65,9 +65,10 @@ module GoToParam
65
65
  GoToParam.allowed_redirect_prefixes.any? { |prefix| go_to_param_value.start_with?(prefix) }
66
66
  end
67
67
 
68
- def go_to_here_path(additional_query_params = {})
68
+ def go_to_here_path(anchor: nil, **additional_query_params)
69
69
  if request.get?
70
- _go_to_add_query_string_from_hash(_go_to_fullpath, additional_query_params)
70
+ path_without_anchor = _go_to_add_query_string_from_hash(_go_to_fullpath, additional_query_params)
71
+ anchor ? path_without_anchor + "#" + anchor : path_without_anchor
71
72
  else
72
73
  nil
73
74
  end
@@ -1,3 +1,3 @@
1
1
  module GoToParam
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -101,6 +101,11 @@ describe GoToParam do
101
101
  expect(controller.go_to_here_params(bar: 3)).to eq({ go_to: "/example?foo&bar=3" })
102
102
  end
103
103
 
104
+ it "accepts an anchor parameter" do
105
+ controller.request = double(get?: true, fullpath: "/example")
106
+ expect(controller.go_to_here_params(foo: "foo", anchor: "bar")).to eq({ go_to: "/example?foo=foo#bar" })
107
+ end
108
+
104
109
  it "makes sure the go_to path is valid UTF-8" do
105
110
  weird_path = "\xE0\x80\x80weird\330stuff".force_encoding("ASCII-8BIT")
106
111
  replacement = "\uFFFD" # The Unicode "Replacement Character".
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_to_param
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik N
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.2
90
+ rubygems_version: 2.5.2
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Rails "go_to" redirection param utilities.