File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ Emitter.prototype.to = function(room){
111
111
*/
112
112
113
113
Emitter . prototype . of = function ( nsp ) {
114
- return new Emitter ( this . redis , this . prefix , nsp ) ;
114
+ return new Emitter ( this . redis , this . prefix , ( nsp [ 0 ] !== "/" ? "/" : "" ) + nsp ) ;
115
115
} ;
116
116
117
117
/**
Original file line number Diff line number Diff line change @@ -106,7 +106,25 @@ describe('emitter', function() {
106
106
} ) ;
107
107
108
108
a . on ( 'broadcast event' , function ( payload ) {
109
- setTimeout ( done , 1000 ) ;
109
+ setTimeout ( ( ) => {
110
+ a . disconnect ( ) ;
111
+ b . disconnect ( ) ;
112
+ done ( ) ;
113
+ } , 1000 ) ;
114
+ } ) ;
115
+ } ) ;
116
+
117
+ it ( 'should prepend a missing / to the namespace name' , ( done ) => {
118
+ const emitter = ioe ( { host : 'localhost' , port : '6379' } ) ;
119
+ const nsp = emitter . of ( 'nsp' ) ; // missing "/"
120
+ const cli = client ( srv , '/nsp' , { forceNew : true } ) ;
121
+ cli . on ( 'connect' , ( ) => {
122
+ nsp . emit ( 'broadcast event' , 'broadacast payload' ) ;
123
+ } ) ;
124
+
125
+ cli . on ( 'broadcast event' , ( ) => {
126
+ cli . disconnect ( ) ;
127
+ done ( ) ;
110
128
} ) ;
111
129
} ) ;
112
130
} ) ;
You can’t perform that action at this time.
0 commit comments