discordrb-webhooks 3.7.1 → 3.7.2

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
  SHA256:
3
- metadata.gz: 64adff3c11dc30cbe5688e48d2dad1b827fc6ef225cfce9d767e21082f3a0469
4
- data.tar.gz: 11bc596b4feb9d4805ab73c313dc918a346ffde62db136fb544231b42f91014a
3
+ metadata.gz: 791e80dc497003f6690ab2bff6727dc35574bdfe9335a99b38ef84581f43f561
4
+ data.tar.gz: f5f096cf7d7f78c0c1a42d803d2e294f425ff64a0b9a5136474dfcfe36c839e2
5
5
  SHA512:
6
- metadata.gz: 5742b179ad21db8f23f73b55da2a6739cf6a7c16b63a3368a83f01c4e7b59c7e72ca26aa17b5f8beceb1aca1a72e6b9431d8d5da158625ef4c199a7ded04e53a
7
- data.tar.gz: 75516b95f3346a5774ddd5e0067613acad2b83bf055b55e4296c14c03b45202d3a9b0113409fab37e8d78f67e7f9df5becaba878b713cfd49bef05889359180e
6
+ metadata.gz: 163c5254987d59a81561b98fc5a8f1bf1634c0503e80431024bb8a535e9d02d916de0b19b4d80e94a29a2dbcc512e8f3cd97e25243cd3cabe12edfbc73c06814
7
+ data.tar.gz: 2f3ad3fa91ace42d5c72c612002664703cbd798beb513798f3acad35c12bae1a111c931c50f415333646388380994cf1a6c938cb61b609c5090eb5584b20f618
@@ -124,20 +124,35 @@ module Discordrb::Webhooks
124
124
  end
125
125
 
126
126
  def post_json(builder, components, wait, thread_id)
127
- query = URI.encode_www_form({ wait:, thread_id: }.compact)
128
127
  data = builder.to_json_hash.merge({ components: components.to_a })
129
- RestClient.post(@url + (query.empty? ? '' : "?#{query}"), data.to_json, content_type: :json)
128
+ RestClient.post(encode_url(wait, thread_id), data.to_json, content_type: :json)
130
129
  end
131
130
 
132
131
  def post_multipart(builder, components, wait, thread_id)
133
- query = URI.encode_www_form({ wait:, thread_id: }.compact)
134
132
  data = builder.to_multipart_hash
135
133
  data[:components] = components.to_a if components&.to_a&.any?
136
- RestClient.post(@url + (query.empty? ? '' : "?#{query}"), data.compact)
134
+ RestClient.post(encode_url(wait, thread_id), data.compact)
137
135
  end
138
136
 
139
137
  def generate_url(id, token)
140
138
  "https://discord.com/api/v9/webhooks/#{id}/#{token}"
141
139
  end
140
+
141
+ def encode_url(wait, thread_id)
142
+ uri = URI.parse(@url)
143
+
144
+ # NOTE: We have to use string keys here, since URI#decode_www_form returns
145
+ # string keys, and keys with different types are treated as array query params
146
+ # and appended to the query params twice.
147
+ query = {
148
+ 'wait' => wait,
149
+ 'thread_id' => thread_id,
150
+ **URI.decode_www_form(uri.query || '').to_h
151
+ }
152
+
153
+ query = URI.encode_www_form(query.compact)
154
+ uri.query = query unless query.empty?
155
+ uri.to_s
156
+ end
142
157
  end
143
158
  end
@@ -4,6 +4,6 @@
4
4
  module Discordrb
5
5
  module Webhooks
6
6
  # The current version of discordrb-webhooks.
7
- VERSION = '3.7.1'
7
+ VERSION = '3.7.2'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discordrb-webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.1
4
+ version: 3.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - meew0