File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,26 @@ exports.connect = (host) => {
1616 // If host is undefined set to local host
1717 if ( ! host ) {
1818 padState . host = 'http://127.0.0.1:9001' ;
19+ padState . path = '' ;
1920 padState . padId = randomString ( ) ;
2021 } else {
2122 const parsed = new URL ( host ) ;
2223 padState . host = `${ parsed . protocol } //${ parsed . host } ` ;
23- padState . padId = parsed . pathname . replace ( '/p/' , '' ) ;
24+ const padIdParam = '/p/' ;
25+ const indexOfPadId = parsed . pathname . indexOf ( padIdParam ) ;
26+ if ( indexOfPadId >= 0 ) {
27+ padState . path = parsed . pathname . substring ( 0 , indexOfPadId )
28+ padState . padId = parsed . pathname . substring ( indexOfPadId + padIdParam . length )
29+ } else {
30+ padState . path = '' ;
31+ padState . padId = randomString ( ) ;
32+ }
2433 }
2534
2635 // Connect to Socket
27- superagent . get ( `${ padState . host } /p/${ padState . padId } ` ) . then ( ( d ) => {
36+ superagent . get ( `${ padState . host } ${ padState . path } /p/${ padState . padId } ` ) . then ( ( d ) => {
2837 const socket = require ( 'socket.io-client' ) ( padState . host , {
38+ 'path' : `${ padState . path } /socket.io` ,
2939 'query' : `padId=${ padState . padId } ` ,
3040 'forceNew' : true ,
3141 'timeout' : 1000 ,
You can’t perform that action at this time.
0 commit comments