File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -225,13 +225,13 @@ io.adapter(redis({ host: 'localhost', port: 6379 }));
225
225
226
226
#### server.origins([ value] )
227
227
228
- - ` value ` _ (String)_
228
+ - ` value ` _ (String|String [ ] )_
229
229
- ** Returns** ` Server|String `
230
230
231
231
Sets the allowed origins ` value ` . Defaults to any origins being allowed. If no arguments are supplied this method returns the current value.
232
232
233
233
``` js
234
- io .origins ([' foo.example.com:443' ]);
234
+ io .origins ([' https:// foo.example.com:443' ]);
235
235
```
236
236
237
237
#### server.origins(fn)
Original file line number Diff line number Diff line change @@ -80,9 +80,11 @@ Server.prototype.checkRequest = function(req, fn) {
80
80
? parts . port
81
81
: defaultPort ;
82
82
var ok =
83
+ ~ this . _origins . indexOf ( parts . protocol + '//' + parts . hostname + ':' + parts . port ) ||
83
84
~ this . _origins . indexOf ( parts . hostname + ':' + parts . port ) ||
84
85
~ this . _origins . indexOf ( parts . hostname + ':*' ) ||
85
86
~ this . _origins . indexOf ( '*:' + parts . port ) ;
87
+ debug ( 'origin %s is %svalid' , origin , ! ! ok ? '' : 'not ' ) ;
86
88
return fn ( null , ! ! ok ) ;
87
89
} catch ( ex ) {
88
90
}
@@ -241,7 +243,7 @@ Server.prototype.adapter = function(v){
241
243
/**
242
244
* Sets the allowed origins for requests.
243
245
*
244
- * @param {String } v origins
246
+ * @param {String|String[] } v origins
245
247
* @return {Server|Adapter } self when setting or value when getting
246
248
* @api public
247
249
*/
Original file line number Diff line number Diff line change @@ -354,6 +354,17 @@ describe('socket.io', function(){
354
354
done ( ) ;
355
355
} ) ;
356
356
} ) ;
357
+
358
+ it ( 'should allow request when using an array of origins' , function ( done ) {
359
+ io ( { origins : [ 'http://foo.example:54024' ] } ) . listen ( '54024' ) ;
360
+ request . get ( 'http://localhost:54024/socket.io/default/' )
361
+ . set ( 'origin' , 'http://foo.example:54024' )
362
+ . query ( { transport : 'polling' } )
363
+ . end ( function ( err , res ) {
364
+ expect ( res . status ) . to . be ( 200 ) ;
365
+ done ( ) ;
366
+ } ) ;
367
+ } ) ;
357
368
} ) ;
358
369
359
370
describe ( 'close' , function ( ) {
You can’t perform that action at this time.
0 commit comments