buttercms-ruby 1.9 → 2.0

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
  SHA256:
3
- metadata.gz: a0f437a3187e885b9c7250f9afbe5ff41cebb2dbc84127dd36ae0963b34fcba1
4
- data.tar.gz: 2a9673e85ef2155f5b55f2febe48932dacf28fc4d7e7fdf4ffa050cb18d69c49
3
+ metadata.gz: 69371855dc4fc9883ba72a8eabd2ede8e8b5118a79b0435457da54609bde25f4
4
+ data.tar.gz: 72c527a3185fc8ed00eb56735bc4e2f3abe343058214cef23ce6debba066c169
5
5
  SHA512:
6
- metadata.gz: 46738145c68da934fc76e9a8e3c8fdaa2ee8e9462e8c07ed69af2ad557cb1e659a657fc164f1573d9d9a5f0fd35b8eceec046f2fae2c40dbe5a518c374cd970a
7
- data.tar.gz: f47192c16cf33c9557aa151e90db0538bf3e3a31dd03e68fe4666cd72093b1c6f95414d640d1121a19eabc491dcbdb10939a8940175de409d7ebcabef4268a65
6
+ metadata.gz: 3c7f9c52c35df85a8ed5f38a3531deddee771529bbb2717c5d5b2cca2a788503a0aecea2672be6bb5f22837a1b453ecbcef7d4f4856dea4b7060e7fc98b74ebf
7
+ data.tar.gz: 70f72d7bf27b9532904b37aff8c40d1060d33511f34d4bcc2d6c0c24aa24ab19f3a9d587b1d132390a672ecfa5c99172ea2c1880cff33263666ce5bf3330d42b
@@ -71,7 +71,13 @@ module ButterCMS
71
71
  query[:test] = 1
72
72
  end
73
73
 
74
- path = "#{@api_url.path}#{URI.encode_www_form(path)}?#{URI.encode_www_form(query)}"
74
+ # If the user has passed in a "/" leading path, don't interpret that
75
+ # as wanting to get rid of the API prefix
76
+ if path.start_with?("/")
77
+ path = path[1..-1]
78
+ end
79
+
80
+ path = Pathname.new(@api_url.path).join(path).to_s + "?#{URI.encode_www_form(query)}"
75
81
 
76
82
  response =
77
83
  Net::HTTP.start(@api_url.host, @api_url.port, http_options) do |http|
@@ -1,3 +1,3 @@
1
1
  module ButterCMS
2
- VERSION = '1.9'
2
+ VERSION = '2.0'
3
3
  end
@@ -14,6 +14,22 @@ describe ButterCMS do
14
14
  ButterCMS.request('')
15
15
  expect(request).to have_been_made
16
16
  end
17
+
18
+ it "should properly escape paths" do
19
+ request = stub_request(
20
+ :get,
21
+ "https://api.buttercms.com/v2/pages/*/homepage%20en?auth_token=test123"
22
+ ).to_return(body: JSON.generate({data: {test: 'test'}}))
23
+
24
+ # support leading slashes
25
+ ButterCMS.request('/pages/*/homepage en')
26
+
27
+ # and no leading slashes
28
+ ButterCMS.request('pages/*/homepage en')
29
+
30
+
31
+ expect(request).to have_been_made.twice
32
+ end
17
33
  end
18
34
 
19
35
  context 'without an api token' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buttercms-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.9'
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCMS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec