@@ -84,21 +84,7 @@ class Server {
84
84
85
85
this . sockets = [ ] ;
86
86
this . contentBaseWatchers = [ ] ;
87
-
88
- // TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
89
87
this . hot = this . options . hot || this . options . hotOnly ;
90
- this . headers = this . options . headers ;
91
- this . progress = this . options . progress ;
92
-
93
- this . serveIndex = this . options . serveIndex ;
94
-
95
- this . clientOverlay = this . options . overlay ;
96
- this . clientLogLevel = this . options . clientLogLevel ;
97
-
98
- this . publicHost = this . options . public ;
99
- this . allowedHosts = this . options . allowedHosts ;
100
- this . disableHostCheck = ! ! this . options . disableHostCheck ;
101
-
102
88
this . watchOptions = options . watchOptions || { } ;
103
89
104
90
// Replace leading and trailing slashes to normalize path
@@ -108,7 +94,7 @@ class Server {
108
94
: 'sockjs-node'
109
95
} `;
110
96
111
- if ( this . progress ) {
97
+ if ( this . options . progress ) {
112
98
this . setupProgressPlugin ( ) ;
113
99
}
114
100
@@ -547,9 +533,10 @@ class Server {
547
533
}
548
534
549
535
// checking if it's set to true or not set (Default : undefined => true)
550
- this . serveIndex = this . serveIndex || this . serveIndex === undefined ;
536
+ this . options . serveIndex =
537
+ this . options . serveIndex || this . options . serveIndex === undefined ;
551
538
552
- if ( this . options . contentBase && this . serveIndex ) {
539
+ if ( this . options . contentBase && this . options . serveIndex ) {
553
540
runnableFeatures . push ( 'contentBaseIndex' ) ;
554
541
}
555
542
@@ -706,8 +693,8 @@ class Server {
706
693
}
707
694
} ) ;
708
695
709
- if ( this . clientLogLevel ) {
710
- this . sockWrite ( [ connection ] , 'log-level' , this . clientLogLevel ) ;
696
+ if ( this . options . clientLogLevel ) {
697
+ this . sockWrite ( [ connection ] , 'log-level' , this . options . clientLogLevel ) ;
711
698
}
712
699
713
700
if ( this . hot ) {
@@ -719,12 +706,12 @@ class Server {
719
706
this . sockWrite ( [ connection ] , 'liveReload' , this . options . liveReload ) ;
720
707
}
721
708
722
- if ( this . progress ) {
723
- this . sockWrite ( [ connection ] , 'progress' , this . progress ) ;
709
+ if ( this . options . progress ) {
710
+ this . sockWrite ( [ connection ] , 'progress' , this . options . progress ) ;
724
711
}
725
712
726
- if ( this . clientOverlay ) {
727
- this . sockWrite ( [ connection ] , 'overlay' , this . clientOverlay ) ;
713
+ if ( this . options . overlay ) {
714
+ this . sockWrite ( [ connection ] , 'overlay' , this . options . overlay ) ;
728
715
}
729
716
730
717
if ( ! this . _stats ) {
@@ -817,10 +804,10 @@ class Server {
817
804
}
818
805
819
806
setContentHeaders ( req , res , next ) {
820
- if ( this . headers ) {
807
+ if ( this . options . headers ) {
821
808
// eslint-disable-next-line
822
- for ( const name in this . headers ) {
823
- res . setHeader ( name , this . headers [ name ] ) ;
809
+ for ( const name in this . options . headers ) {
810
+ res . setHeader ( name , this . options . headers [ name ] ) ;
824
811
}
825
812
}
826
813
@@ -836,8 +823,10 @@ class Server {
836
823
}
837
824
838
825
checkHeaders ( headers , headerToCheck ) {
826
+ const optionsDisableHostCheck = ! ! this . options . disableHostCheck ;
827
+
839
828
// allow user to opt-out this security check, at own risk
840
- if ( this . disableHostCheck ) {
829
+ if ( optionsDisableHostCheck ) {
841
830
return true ;
842
831
}
843
832
@@ -879,9 +868,13 @@ class Server {
879
868
}
880
869
// always allow localhost host, for convenience
881
870
// allow if hostname is in allowedHosts
882
- if ( this . allowedHosts && this . allowedHosts . length ) {
883
- for ( let hostIdx = 0 ; hostIdx < this . allowedHosts . length ; hostIdx ++ ) {
884
- const allowedHost = this . allowedHosts [ hostIdx ] ;
871
+ if ( this . options . allowedHosts && this . options . allowedHosts . length ) {
872
+ for (
873
+ let hostIdx = 0 ;
874
+ hostIdx < this . options . allowedHosts . length ;
875
+ hostIdx ++
876
+ ) {
877
+ const allowedHost = this . options . allowedHosts [ hostIdx ] ;
885
878
886
879
if ( allowedHost === hostname ) {
887
880
return true ;
@@ -903,10 +896,12 @@ class Server {
903
896
}
904
897
905
898
// also allow public hostname if provided
906
- if ( typeof this . publicHost === 'string' ) {
907
- const idxPublic = this . publicHost . indexOf ( ':' ) ;
899
+ if ( typeof this . options . public === 'string' ) {
900
+ const idxPublic = this . options . public . indexOf ( ':' ) ;
908
901
const publicHostname =
909
- idxPublic >= 0 ? this . publicHost . substr ( 0 , idxPublic ) : this . publicHost ;
902
+ idxPublic >= 0
903
+ ? this . options . public . substr ( 0 , idxPublic )
904
+ : this . options . public ;
910
905
911
906
if ( hostname === publicHostname ) {
912
907
return true ;
0 commit comments