Skip to content

Commit

Permalink
Set path to / when no path is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
imanel committed Nov 18, 2012
1 parent 23cf28d commit 4147555
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/websocket/handshake/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def initialize(args = {})
@version = args[:version] || DEFAULT_VERSION
@origin = args[:origin]

if args[:uri] || args[:url]
uri = URI.parse(args[:uri] || args[:url])
if args[:url] || args[:uri]
uri = URI.parse(args[:url] || args[:uri])
@secure = (uri.scheme == 'wss')
@host = uri.host
@port = uri.port
Expand Down
21 changes: 21 additions & 0 deletions spec/support/all_client_drafts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ def validate_request
handshake.port.should eql(123)
end

it "should parse uri" do
@request_params = { :uri => "ws://test.example.org:301/test_path?query=true" }
handshake.host.should eql('test.example.org')
handshake.port.should eql(301)
handshake.path.should eql('/test_path')
handshake.query.should eql('query=true')
end

it "should parse url" do
@request_params = { :url => "ws://test.example.org:301/test_path?query=true" }
handshake.host.should eql('test.example.org')
handshake.port.should eql(301)
handshake.path.should eql('/test_path')
handshake.query.should eql('query=true')
end

it "should resolve correct path with root server provided" do
@request_params = { :url => "ws://test.example.org" }
handshake.path.should eql('/')
end

it "should return valid response" do
validate_request
end
Expand Down

0 comments on commit 4147555

Please sign in to comment.