@@ -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
@@ -530,9 +516,10 @@ class Server {
530
516
}
531
517
532
518
// checking if it's set to true or not set (Default : undefined => true)
533
- this . serveIndex = this . serveIndex || this . serveIndex === undefined ;
519
+ this . options . serveIndex =
520
+ this . options . serveIndex || this . options . serveIndex === undefined ;
534
521
535
- if ( this . options . contentBase && this . serveIndex ) {
522
+ if ( this . options . contentBase && this . options . serveIndex ) {
536
523
runnableFeatures . push ( 'contentBaseIndex' ) ;
537
524
}
538
525
@@ -689,8 +676,8 @@ class Server {
689
676
}
690
677
} ) ;
691
678
692
- if ( this . clientLogLevel ) {
693
- this . sockWrite ( [ connection ] , 'log-level' , this . clientLogLevel ) ;
679
+ if ( this . options . clientLogLevel ) {
680
+ this . sockWrite ( [ connection ] , 'log-level' , this . options . clientLogLevel ) ;
694
681
}
695
682
696
683
if ( this . hot ) {
@@ -702,12 +689,12 @@ class Server {
702
689
this . sockWrite ( [ connection ] , 'liveReload' , this . options . liveReload ) ;
703
690
}
704
691
705
- if ( this . progress ) {
706
- this . sockWrite ( [ connection ] , 'progress' , this . progress ) ;
692
+ if ( this . options . progress ) {
693
+ this . sockWrite ( [ connection ] , 'progress' , this . options . progress ) ;
707
694
}
708
695
709
- if ( this . clientOverlay ) {
710
- this . sockWrite ( [ connection ] , 'overlay' , this . clientOverlay ) ;
696
+ if ( this . options . overlay ) {
697
+ this . sockWrite ( [ connection ] , 'overlay' , this . options . overlay ) ;
711
698
}
712
699
713
700
if ( ! this . _stats ) {
@@ -800,10 +787,10 @@ class Server {
800
787
}
801
788
802
789
setContentHeaders ( req , res , next ) {
803
- if ( this . headers ) {
790
+ if ( this . options . headers ) {
804
791
// eslint-disable-next-line
805
- for ( const name in this . headers ) {
806
- res . setHeader ( name , this . headers [ name ] ) ;
792
+ for ( const name in this . options . headers ) {
793
+ res . setHeader ( name , this . options . headers [ name ] ) ;
807
794
}
808
795
}
809
796
@@ -819,8 +806,10 @@ class Server {
819
806
}
820
807
821
808
checkHeaders ( headers , headerToCheck ) {
809
+ const optionsDisableHostCheck = ! ! this . options . disableHostCheck ;
810
+
822
811
// allow user to opt-out this security check, at own risk
823
- if ( this . disableHostCheck ) {
812
+ if ( optionsDisableHostCheck ) {
824
813
return true ;
825
814
}
826
815
@@ -862,9 +851,13 @@ class Server {
862
851
}
863
852
// always allow localhost host, for convenience
864
853
// allow if hostname is in allowedHosts
865
- if ( this . allowedHosts && this . allowedHosts . length ) {
866
- for ( let hostIdx = 0 ; hostIdx < this . allowedHosts . length ; hostIdx ++ ) {
867
- const allowedHost = this . allowedHosts [ hostIdx ] ;
854
+ if ( this . options . allowedHosts && this . options . allowedHosts . length ) {
855
+ for (
856
+ let hostIdx = 0 ;
857
+ hostIdx < this . options . allowedHosts . length ;
858
+ hostIdx ++
859
+ ) {
860
+ const allowedHost = this . options . allowedHosts [ hostIdx ] ;
868
861
869
862
if ( allowedHost === hostname ) {
870
863
return true ;
@@ -886,10 +879,12 @@ class Server {
886
879
}
887
880
888
881
// also allow public hostname if provided
889
- if ( typeof this . publicHost === 'string' ) {
890
- const idxPublic = this . publicHost . indexOf ( ':' ) ;
882
+ if ( typeof this . options . public === 'string' ) {
883
+ const idxPublic = this . options . public . indexOf ( ':' ) ;
891
884
const publicHostname =
892
- idxPublic >= 0 ? this . publicHost . substr ( 0 , idxPublic ) : this . publicHost ;
885
+ idxPublic >= 0
886
+ ? this . options . public . substr ( 0 , idxPublic )
887
+ : this . options . public ;
893
888
894
889
if ( hostname === publicHostname ) {
895
890
return true ;
0 commit comments