bypass 0.0.5 → 0.0.6
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/lib/bypass/uri.rb +9 -2
- data/lib/bypass/version.rb +1 -1
- data/test/bypass/uri_test.rb +37 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241540206797fc2ee8bb927912833a4ee8146acc
|
4
|
+
data.tar.gz: 3d107907b49d2a7ff4bfc1852212fef76f05dbbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34514af9628da625ad96c9d20b070fa890b0bdf252105f1b2c62c88ee7ddc81c79b1abfe0ea26c6e2277dc89ffbafad984dec87368f4166eb2aa1528da59797
|
7
|
+
data.tar.gz: 30a6d0eab06f840b8308c32b28c823a61ff8025acf273c51c4483f21770796dd3c33e50f8d4b7a051b6daff35978d17137f56d8dc3f7e0c57fe198f5df11f44b
|
data/lib/bypass/uri.rb
CHANGED
@@ -3,7 +3,14 @@ require "addressable/uri"
|
|
3
3
|
module Bypass
|
4
4
|
class URI < Addressable::URI
|
5
5
|
def append_to_query_values(params = {})
|
6
|
-
|
6
|
+
pairs = params.keys.map do |raw_key|
|
7
|
+
key = self.class.encode(raw_key.to_s)
|
8
|
+
val = self.class.encode(params[raw_key])
|
9
|
+
[key, val].join("=")
|
10
|
+
end
|
11
|
+
|
12
|
+
pairs.unshift(query) if query
|
13
|
+
self.query = pairs.join("&")
|
7
14
|
end
|
8
15
|
end
|
9
|
-
end
|
16
|
+
end
|
data/lib/bypass/version.rb
CHANGED
data/test/bypass/uri_test.rb
CHANGED
@@ -7,5 +7,41 @@ class Bypass::URITest < MiniTest::Test
|
|
7
7
|
uri.append_to_query_values(:foo => "bar")
|
8
8
|
assert_equal "http://www.getdrip.com?foo=bar", uri.to_s
|
9
9
|
end
|
10
|
+
|
11
|
+
should "add mulitple values" do
|
12
|
+
uri = Bypass::URI.parse("http://www.getdrip.com")
|
13
|
+
uri.append_to_query_values(:foo => "bar", :name => "Ian")
|
14
|
+
assert_equal "http://www.getdrip.com?foo=bar&name=Ian", uri.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
should "append to the existing query string" do
|
18
|
+
uri = Bypass::URI.parse("http://www.getdrip.com?foo=bar")
|
19
|
+
uri.append_to_query_values(:name => "Ian")
|
20
|
+
assert_equal "http://www.getdrip.com?foo=bar&name=Ian", uri.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
should "support array-style keys" do
|
24
|
+
uri = Bypass::URI.parse("http://www.getdrip.com?foo[]=bar1&foo[]=bar2")
|
25
|
+
uri.append_to_query_values(:name => "Ian")
|
26
|
+
assert_equal "http://www.getdrip.com?foo[]=bar1&foo[]=bar2&name=Ian", uri.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
should "not attempt to merge duplicate keys" do
|
30
|
+
uri = Bypass::URI.parse("http://www.getdrip.com?name=Ian")
|
31
|
+
uri.append_to_query_values(:name => "Derrick")
|
32
|
+
assert_equal "http://www.getdrip.com?name=Ian&name=Derrick", uri.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
should "encode keys" do
|
36
|
+
uri = Bypass::URI.parse("http://www.getdrip.com")
|
37
|
+
uri.append_to_query_values("first name" => "Ian")
|
38
|
+
assert_equal "http://www.getdrip.com?first%20name=Ian", uri.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
should "encode values" do
|
42
|
+
uri = Bypass::URI.parse("http://www.getdrip.com")
|
43
|
+
uri.append_to_query_values(:name => "Ian Nance")
|
44
|
+
assert_equal "http://www.getdrip.com?name=Ian%20Nance", uri.to_s
|
45
|
+
end
|
10
46
|
end
|
11
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bypass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -134,3 +134,4 @@ test_files:
|
|
134
134
|
- test/bypass/text_filter_test.rb
|
135
135
|
- test/bypass/uri_test.rb
|
136
136
|
- test/test_helper.rb
|
137
|
+
has_rdoc:
|