Skip to content

Commit e45d2cc

Browse files
authored
Deduplicate channels and groups in request building (#173)
feat(subscribe): deduplicate channels and groups in request building Add `.uniq` calls when building subscribe URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests. feat(heartbeat): deduplicate channels and groups in request building Add `.uniq` calls when building heartbeat URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests.
1 parent b2540e2 commit e45d2cc

File tree

12 files changed

+125
-52
lines changed

12 files changed

+125
-52
lines changed

.pubnub.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
---
2-
version: "6.0.1"
2+
version: "6.0.2"
33
changelog:
4+
- date: 2026-03-03
5+
version: v6.0.2
6+
changes:
7+
- type: improvement
8+
text: "Add `.uniq` calls when building subscribe URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests."
9+
- type: improvement
10+
text: "Add `.uniq` calls when building heartbeat URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests."
411
- date: 2025-11-04
512
version: v6.0.1
613
changes:
@@ -627,7 +634,7 @@ sdks:
627634
- x86-64
628635
- distribution-type: package
629636
distribution-repository: RubyGems
630-
package-name: pubnub-6.0.1.gem
637+
package-name: pubnub-6.0.2.gem
631638
location: https://rubygems.org/gems/pubnub
632639
requires:
633640
- name: addressable
@@ -732,8 +739,8 @@ sdks:
732739
- x86-64
733740
- distribution-type: library
734741
distribution-repository: GitHub release
735-
package-name: pubnub-6.0.1.gem
736-
location: https://github.com/pubnub/ruby/releases/download/v6.0.1/pubnub-6.0.1.gem
742+
package-name: pubnub-6.0.2.gem
743+
location: https://github.com/pubnub/ruby/releases/download/v6.0.2/pubnub-6.0.2.gem
737744
requires:
738745
- name: addressable
739746
min-version: 2.0.0

CHANGELOG.md

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
1-
## v6.0.1
2-
November 04 2025
3-
4-
#### Fixed
5-
- Send proper object for `state` with the `heartbeat` request.
6-
7-
#### Modified
8-
- Don't cap `limit` and let the server perform value validation.
9-
- Replace legacy timetoken query parameter with subscribe v2 parameters.
10-
11-
## v6.0.0
12-
October 15 2025
13-
14-
#### Added
15-
- BREAKING CHANGES: Add 'limit' and 'offset' parameters for 'here_now' for pagination support.
16-
17-
## v5.6.0
18-
September 11 2025
19-
20-
#### Added
21-
- Add the `encode_channels` parameter for `fetch` to enable or disable channel names percent-encoding in response.
22-
23-
## v5.5.1
24-
September 08 2025
25-
26-
#### Fixed
27-
- Fix the issue introduced by RuboCop linter suggestion acceptance, which caused a wrong number of arguments error.
28-
29-
## v5.5.0
30-
January 28 2025
31-
32-
#### Added
33-
- Add the ability to specify `type` and `status` fields for `channel metadata`, `uuid metadata`, `member`, and `membership`.
34-
- Add missing `include` options for App Context APIs: `custom`, `status`, `type`, `uuid_status`, `uuid_type`, `channel_status`, and `channel_type`.
35-
1+
## v6.0.2
2+
March 03 2026
3+
4+
#### Modified
5+
- Add `.uniq` calls when building subscribe URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests.
6+
- Add `.uniq` calls when building heartbeat URL path and channel-group query parameter to prevent duplicate channels and channel groups from leaking into HTTP requests.
7+
8+
## v6.0.1
9+
November 04 2025
10+
11+
#### Fixed
12+
- Send proper object for `state` with the `heartbeat` request.
13+
14+
#### Modified
15+
- Don't cap `limit` and let the server perform value validation.
16+
- Replace legacy timetoken query parameter with subscribe v2 parameters.
17+
18+
## v6.0.0
19+
October 15 2025
20+
21+
#### Added
22+
- BREAKING CHANGES: Add 'limit' and 'offset' parameters for 'here_now' for pagination support.
23+
24+
## v5.6.0
25+
September 11 2025
26+
27+
#### Added
28+
- Add the `encode_channels` parameter for `fetch` to enable or disable channel names percent-encoding in response.
29+
30+
## v5.5.1
31+
September 08 2025
32+
33+
#### Fixed
34+
- Fix the issue introduced by RuboCop linter suggestion acceptance, which caused a wrong number of arguments error.
35+
36+
## v5.5.0
37+
January 28 2025
38+
39+
#### Added
40+
- Add the ability to specify `type` and `status` fields for `channel metadata`, `uuid metadata`, `member`, and `membership`.
41+
- Add missing `include` options for App Context APIs: `custom`, `status`, `type`, `uuid_status`, `uuid_type`, `channel_status`, and `channel_type`.
42+
3643
## v5.4.0
3744
January 07 2025
3845

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
pubnub (6.0.1)
4+
pubnub (6.0.2)
55
addressable (>= 2.0.0)
66
concurrent-ruby (~> 1.3.4)
77
concurrent-ruby-edge (~> 0.7.1)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.0.1
1+
6.0.2

fixtures/vcr_cassettes/examples/presence/0.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/vcr_cassettes/examples/presence/1.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/vcr_cassettes/examples/presence/2.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/vcr_cassettes/lib/events/heartbeat-unique.yml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/pubnub/events/heartbeat.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def path
2525
'sub-key',
2626
@subscribe_key,
2727
'channel',
28-
Formatter.channels_for_url(@channel),
28+
Formatter.channels_for_url(@channel.uniq),
2929
'heartbeat'
3030
].join('/')
3131
end
@@ -37,7 +37,7 @@ def parameters(*_args)
3737
parameters.delete(:state) if parameters[:state] == '%7B%7D'
3838
end
3939
parameters[:heartbeat] = @heartbeat
40-
parameters['channel-group'] = @group.join(',') unless @group.blank?
40+
parameters['channel-group'] = @group.uniq.join(',') unless @group.blank?
4141
parameters
4242
end
4343

lib/pubnub/subscribe_event.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def path
124124
'v2',
125125
'subscribe',
126126
@subscribe_key,
127-
Pubnub::Formatter.channels_for_url(@channel + @wildcard_channel),
127+
Pubnub::Formatter.channels_for_url((@channel + @wildcard_channel).uniq),
128128
0
129129
].join('/').gsub(/\?/, '%3F')
130130
end
@@ -151,7 +151,7 @@ def add_timetoken_to_params(params)
151151
end
152152

153153
def add_group_to_params(params)
154-
params['channel-group'] = @group.join(',') unless @group.empty?
154+
params['channel-group'] = @group.uniq.join(',') unless @group.empty?
155155
params
156156
end
157157

0 commit comments

Comments
 (0)