Skip to content

Commit 102a90e

Browse files
Bugfix, another regex problem
1 parent 8831809 commit 102a90e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/pusher/channel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def authenticate(socket_id, custom_data = nil)
170170
private
171171

172172
def validate_socket_id(socket_id)
173-
unless socket_id && /\d+\.\d+$/.match(socket_id)
173+
unless socket_id && /^\d+\.\d+$/.match(socket_id)
174174
raise Pusher::Error, "Invalid socket ID #{socket_id.inspect}"
175175
end
176176
end

spec/channel_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ def authentication_string(*data)
152152
@channel.authenticate('1.1foo', 'channel')
153153
}.should raise_error Pusher::Error
154154

155+
lambda {
156+
@channel.authenticate(':1.1')
157+
}.should raise_error Pusher::Error
158+
159+
lambda {
160+
@channel.authenticate('foo1.1', 'channel')
161+
}.should raise_error Pusher::Error
162+
155163
lambda {
156164
@channel.authenticate('foo', 'channel')
157165
}.should raise_error Pusher::Error

0 commit comments

Comments
 (0)