@@ -89,21 +89,7 @@ class Server {
89
89
90
90
this . sockets = [ ] ;
91
91
this . contentBaseWatchers = [ ] ;
92
-
93
- // TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
94
92
this . hot = this . options . hot || this . options . hotOnly ;
95
- this . headers = this . options . headers ;
96
- this . progress = this . options . progress ;
97
-
98
- this . serveIndex = this . options . serveIndex ;
99
-
100
- this . clientOverlay = this . options . overlay ;
101
- this . clientLogLevel = this . options . clientLogLevel ;
102
-
103
- this . publicHost = this . options . public ;
104
- this . allowedHosts = this . options . allowedHosts ;
105
- this . disableHostCheck = ! ! this . options . disableHostCheck ;
106
-
107
93
this . watchOptions = options . watchOptions || { } ;
108
94
109
95
// Replace leading and trailing slashes to normalize path
@@ -113,7 +99,7 @@ class Server {
113
99
: 'sockjs-node'
114
100
} `;
115
101
116
- if ( this . progress ) {
102
+ if ( this . options . progress ) {
117
103
this . setupProgressPlugin ( ) ;
118
104
}
119
105
@@ -536,9 +522,10 @@ class Server {
536
522
}
537
523
538
524
// checking if it's set to true or not set (Default : undefined => true)
539
- this . serveIndex = this . serveIndex || this . serveIndex === undefined ;
525
+ this . options . serveIndex =
526
+ this . options . serveIndex || this . options . serveIndex === undefined ;
540
527
541
- if ( this . options . contentBase && this . serveIndex ) {
528
+ if ( this . options . contentBase && this . options . serveIndex ) {
542
529
runnableFeatures . push ( 'contentBaseIndex' ) ;
543
530
}
544
531
@@ -695,8 +682,8 @@ class Server {
695
682
}
696
683
} ) ;
697
684
698
- if ( this . clientLogLevel ) {
699
- this . sockWrite ( [ connection ] , 'log-level' , this . clientLogLevel ) ;
685
+ if ( this . options . clientLogLevel ) {
686
+ this . sockWrite ( [ connection ] , 'log-level' , this . options . clientLogLevel ) ;
700
687
}
701
688
702
689
if ( this . hot ) {
@@ -708,12 +695,12 @@ class Server {
708
695
this . sockWrite ( [ connection ] , 'liveReload' , this . options . liveReload ) ;
709
696
}
710
697
711
- if ( this . progress ) {
712
- this . sockWrite ( [ connection ] , 'progress' , this . progress ) ;
698
+ if ( this . options . progress ) {
699
+ this . sockWrite ( [ connection ] , 'progress' , this . options . progress ) ;
713
700
}
714
701
715
- if ( this . clientOverlay ) {
716
- this . sockWrite ( [ connection ] , 'overlay' , this . clientOverlay ) ;
702
+ if ( this . options . overlay ) {
703
+ this . sockWrite ( [ connection ] , 'overlay' , this . options . overlay ) ;
717
704
}
718
705
719
706
if ( ! this . _stats ) {
@@ -806,10 +793,10 @@ class Server {
806
793
}
807
794
808
795
setContentHeaders ( req , res , next ) {
809
- if ( this . headers ) {
796
+ if ( this . options . headers ) {
810
797
// eslint-disable-next-line
811
- for ( const name in this . headers ) {
812
- res . setHeader ( name , this . headers [ name ] ) ;
798
+ for ( const name in this . options . headers ) {
799
+ res . setHeader ( name , this . options . headers [ name ] ) ;
813
800
}
814
801
}
815
802
@@ -825,8 +812,10 @@ class Server {
825
812
}
826
813
827
814
checkHeaders ( headers , headerToCheck ) {
815
+ const optionsDisableHostCheck = ! ! this . options . disableHostCheck ;
816
+
828
817
// allow user to opt-out this security check, at own risk
829
- if ( this . disableHostCheck ) {
818
+ if ( optionsDisableHostCheck ) {
830
819
return true ;
831
820
}
832
821
@@ -868,9 +857,13 @@ class Server {
868
857
}
869
858
// always allow localhost host, for convenience
870
859
// allow if hostname is in allowedHosts
871
- if ( this . allowedHosts && this . allowedHosts . length ) {
872
- for ( let hostIdx = 0 ; hostIdx < this . allowedHosts . length ; hostIdx ++ ) {
873
- const allowedHost = this . allowedHosts [ hostIdx ] ;
860
+ if ( this . options . allowedHosts && this . options . allowedHosts . length ) {
861
+ for (
862
+ let hostIdx = 0 ;
863
+ hostIdx < this . options . allowedHosts . length ;
864
+ hostIdx ++
865
+ ) {
866
+ const allowedHost = this . options . allowedHosts [ hostIdx ] ;
874
867
875
868
if ( allowedHost === hostname ) {
876
869
return true ;
@@ -892,10 +885,12 @@ class Server {
892
885
}
893
886
894
887
// also allow public hostname if provided
895
- if ( typeof this . publicHost === 'string' ) {
896
- const idxPublic = this . publicHost . indexOf ( ':' ) ;
888
+ if ( typeof this . options . public === 'string' ) {
889
+ const idxPublic = this . options . public . indexOf ( ':' ) ;
897
890
const publicHostname =
898
- idxPublic >= 0 ? this . publicHost . substr ( 0 , idxPublic ) : this . publicHost ;
891
+ idxPublic >= 0
892
+ ? this . options . public . substr ( 0 , idxPublic )
893
+ : this . options . public ;
899
894
900
895
if ( hostname === publicHostname ) {
901
896
return true ;
0 commit comments