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 +4 -4
- data/README.md +2 -0
- data/lib/go_to_param.rb +3 -2
- data/lib/go_to_param/version.rb +1 -1
- data/spec/go_to_param_spec.rb +5 -0
- 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: 19bbfd139f7a3c04cae82b201603264929282a8d
|
4
|
+
data.tar.gz: 664fd95648b290ccbdc9f5084d3ea6ed3ea54ee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
data/lib/go_to_param/version.rb
CHANGED
data/spec/go_to_param_spec.rb
CHANGED
@@ -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.
|
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:
|
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.
|
90
|
+
rubygems_version: 2.5.2
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Rails "go_to" redirection param utilities.
|