bypass 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 718e8ae5c353526d782ccaa70459e5f5dc70b84f
4
- data.tar.gz: 870eadce1dfe1ba0fe41625d12527fe3fa09c03b
3
+ metadata.gz: 241540206797fc2ee8bb927912833a4ee8146acc
4
+ data.tar.gz: 3d107907b49d2a7ff4bfc1852212fef76f05dbbe
5
5
  SHA512:
6
- metadata.gz: 6a11749670fe237ebe686e126a9620ed2463c9855284290850c9ca81cf85d14f7c5e679b70543006986ec668d18538ced58ec7e21b889dad8ec79bf43aa02a55
7
- data.tar.gz: a2d4dfcd1fc1ff96b30452dc251bfff9a1826fd6de7e860016a2ff00cc1584ba43d6ad33232b23d867f4850fd6b9f2eef6200bae7b6d16af3ddfdadfef42f66e
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
- self.query_values = (query_values || {}).merge(params)
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
@@ -1,3 +1,3 @@
1
1
  module Bypass
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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.5
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: 2014-08-26 00:00:00.000000000 Z
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: