This repository was archived by the owner on Nov 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed
Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -45,23 +45,27 @@ export class PrivateChannel {
4545 * @return {string }
4646 */
4747 protected authHost ( socket : any ) : string {
48- let referer = url . parse ( socket . request . headers . referer ) ;
49- let authHostSelected = 'http://localhost' ;
50- let authHosts = ( this . options . authHost ) ?
51- this . options . authHost : this . options . host ;
52-
53- if ( typeof authHosts === "string" ) {
54- authHosts = [ authHosts ] ;
55- }
56-
57- for ( let authHost of authHosts ) {
58- authHostSelected = authHost ;
59-
60- if ( this . hasMatchingHost ( referer , authHost ) ) {
61- authHostSelected = `${ referer . protocol } //${ referer . host } ` ;
62- break ;
63- }
64- } ;
48+ let authHosts = ( this . options . authHost ) ?
49+ this . options . authHost : this . options . host ;
50+
51+ if ( typeof authHosts === "string" ) {
52+ authHosts = [ authHosts ] ;
53+ }
54+
55+ let authHostSelected = authHosts [ 0 ] || 'http://localhost' ;
56+
57+ if ( socket . request . headers . referer ) {
58+ let referer = url . parse ( socket . request . headers . referer ) ;
59+
60+ for ( let authHost of authHosts ) {
61+ authHostSelected = authHost ;
62+
63+ if ( this . hasMatchingHost ( referer , authHost ) ) {
64+ authHostSelected = `${ referer . protocol } //${ referer . host } ` ;
65+ break ;
66+ }
67+ } ;
68+ }
6569
6670 return authHostSelected ;
6771 }
You can’t perform that action at this time.
0 commit comments