File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ function vhost (hostname, handle) {
74
74
*/
75
75
76
76
function hostnameof ( req ) {
77
- var host = req . headers . host ? req . headers . host : req . headers [ ':authority' ]
77
+ var host = ishttp2 ( req ) ? req . headers [ ':authority' ] : req . headers . host
78
78
79
79
if ( ! host ) {
80
80
return
@@ -137,7 +137,7 @@ function hostregexp (val) {
137
137
*/
138
138
139
139
function vhostof ( req , regexp ) {
140
- var host = req . headers . host ? req . headers . host : req . headers [ ':authority' ]
140
+ var host = ishttp2 ( req ) ? req . headers [ ':authority' ] : req . headers . host
141
141
var hostname = hostnameof ( req )
142
142
143
143
if ( ! hostname ) {
@@ -162,3 +162,15 @@ function vhostof (req, regexp) {
162
162
163
163
return obj
164
164
}
165
+
166
+ /**
167
+ * Check if a request is a http2 request.
168
+ *
169
+ * @param {Object } request
170
+ * @return {Boolean }
171
+ * @public
172
+ */
173
+
174
+ function ishttp2 ( req ) {
175
+ return req . httpVersionMajor === 2
176
+ }
You can’t perform that action at this time.
0 commit comments