File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,8 +72,11 @@ export class SocketIO {
7272 if ( server . search ( / ^ h t t p s ? : \/ \/ / ) == - 1 ) {
7373 server = 'http://' + this . server ;
7474 }
75-
76- this . socket = io ( server + '/' + this . gameName , this . socketOpts ) ;
75+ if ( server . substr ( - 1 ) != '/' ) {
76+ // add trailing slash if not already present
77+ server = server + '/' ;
78+ }
79+ this . socket = io ( server + this . gameName , this . socketOpts ) ;
7780 } else {
7881 this . socket = io ( '/' + this . gameName , this . socketOpts ) ;
7982 }
Original file line number Diff line number Diff line change @@ -144,6 +144,13 @@ describe('server option', () => {
144144 expect ( m . socket . io . engine . secure ) . toEqual ( false ) ;
145145 } ) ;
146146
147+ test ( 'without trailing slash' , ( ) => {
148+ const server = 'http://' + hostname + ':' + port ;
149+ const m = new SocketIO ( { server } ) ;
150+ m . connect ( ) ;
151+ expect ( m . socket . io . uri ) . toEqual ( server + '/default' ) ;
152+ } ) ;
153+
147154 test ( 'https' , ( ) => {
148155 const serverWithProtocol = 'https://' + hostname + ':' + port + '/' ;
149156 const m = new SocketIO ( { server : serverWithProtocol } ) ;
You can’t perform that action at this time.
0 commit comments