@@ -83,21 +83,7 @@ class Server {
83
83
84
84
this . sockets = [ ] ;
85
85
this . contentBaseWatchers = [ ] ;
86
-
87
- // TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
88
86
this . hot = this . options . hot || this . options . hotOnly ;
89
- this . headers = this . options . headers ;
90
- this . progress = this . options . progress ;
91
-
92
- this . serveIndex = this . options . serveIndex ;
93
-
94
- this . clientOverlay = this . options . overlay ;
95
- this . clientLogLevel = this . options . clientLogLevel ;
96
-
97
- this . publicHost = this . options . public ;
98
- this . allowedHosts = this . options . allowedHosts ;
99
- this . disableHostCheck = ! ! this . options . disableHostCheck ;
100
-
101
87
this . watchOptions = options . watchOptions || { } ;
102
88
103
89
// Replace leading and trailing slashes to normalize path
@@ -107,7 +93,7 @@ class Server {
107
93
: 'sockjs-node'
108
94
} `;
109
95
110
- if ( this . progress ) {
96
+ if ( this . options . progress ) {
111
97
this . setupProgressPlugin ( ) ;
112
98
}
113
99
@@ -532,9 +518,10 @@ class Server {
532
518
}
533
519
534
520
// checking if it's set to true or not set (Default : undefined => true)
535
- this . serveIndex = this . serveIndex || this . serveIndex === undefined ;
521
+ this . options . serveIndex =
522
+ this . options . serveIndex || this . options . serveIndex === undefined ;
536
523
537
- if ( this . options . contentBase && this . serveIndex ) {
524
+ if ( this . options . contentBase && this . options . serveIndex ) {
538
525
runnableFeatures . push ( 'contentBaseIndex' ) ;
539
526
}
540
527
@@ -691,8 +678,8 @@ class Server {
691
678
}
692
679
} ) ;
693
680
694
- if ( this . clientLogLevel ) {
695
- this . sockWrite ( [ connection ] , 'log-level' , this . clientLogLevel ) ;
681
+ if ( this . options . clientLogLevel ) {
682
+ this . sockWrite ( [ connection ] , 'log-level' , this . options . clientLogLevel ) ;
696
683
}
697
684
698
685
if ( this . hot ) {
@@ -704,12 +691,12 @@ class Server {
704
691
this . sockWrite ( [ connection ] , 'liveReload' , this . options . liveReload ) ;
705
692
}
706
693
707
- if ( this . progress ) {
708
- this . sockWrite ( [ connection ] , 'progress' , this . progress ) ;
694
+ if ( this . options . progress ) {
695
+ this . sockWrite ( [ connection ] , 'progress' , this . options . progress ) ;
709
696
}
710
697
711
- if ( this . clientOverlay ) {
712
- this . sockWrite ( [ connection ] , 'overlay' , this . clientOverlay ) ;
698
+ if ( this . options . overlay ) {
699
+ this . sockWrite ( [ connection ] , 'overlay' , this . options . overlay ) ;
713
700
}
714
701
715
702
if ( ! this . _stats ) {
@@ -802,10 +789,10 @@ class Server {
802
789
}
803
790
804
791
setContentHeaders ( req , res , next ) {
805
- if ( this . headers ) {
792
+ if ( this . options . headers ) {
806
793
// eslint-disable-next-line
807
- for ( const name in this . headers ) {
808
- res . setHeader ( name , this . headers [ name ] ) ;
794
+ for ( const name in this . options . headers ) {
795
+ res . setHeader ( name , this . options . headers [ name ] ) ;
809
796
}
810
797
}
811
798
@@ -821,8 +808,10 @@ class Server {
821
808
}
822
809
823
810
checkHeaders ( headers , headerToCheck ) {
811
+ const optionsDisableHostCheck = ! ! this . options . disableHostCheck ;
812
+
824
813
// allow user to opt-out this security check, at own risk
825
- if ( this . disableHostCheck ) {
814
+ if ( optionsDisableHostCheck ) {
826
815
return true ;
827
816
}
828
817
@@ -864,9 +853,13 @@ class Server {
864
853
}
865
854
// always allow localhost host, for convenience
866
855
// allow if hostname is in allowedHosts
867
- if ( this . allowedHosts && this . allowedHosts . length ) {
868
- for ( let hostIdx = 0 ; hostIdx < this . allowedHosts . length ; hostIdx ++ ) {
869
- const allowedHost = this . allowedHosts [ hostIdx ] ;
856
+ if ( this . options . allowedHosts && this . options . allowedHosts . length ) {
857
+ for (
858
+ let hostIdx = 0 ;
859
+ hostIdx < this . options . allowedHosts . length ;
860
+ hostIdx ++
861
+ ) {
862
+ const allowedHost = this . options . allowedHosts [ hostIdx ] ;
870
863
871
864
if ( allowedHost === hostname ) {
872
865
return true ;
@@ -888,10 +881,12 @@ class Server {
888
881
}
889
882
890
883
// also allow public hostname if provided
891
- if ( typeof this . publicHost === 'string' ) {
892
- const idxPublic = this . publicHost . indexOf ( ':' ) ;
884
+ if ( typeof this . options . public === 'string' ) {
885
+ const idxPublic = this . options . public . indexOf ( ':' ) ;
893
886
const publicHostname =
894
- idxPublic >= 0 ? this . publicHost . substr ( 0 , idxPublic ) : this . publicHost ;
887
+ idxPublic >= 0
888
+ ? this . options . public . substr ( 0 , idxPublic )
889
+ : this . options . public ;
895
890
896
891
if ( hostname === publicHostname ) {
897
892
return true ;
0 commit comments