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) {
7474 */
7575
7676function 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
7878
7979 if ( ! host ) {
8080 return
@@ -137,7 +137,7 @@ function hostregexp (val) {
137137 */
138138
139139function 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
141141 var hostname = hostnameof ( req )
142142
143143 if ( ! hostname ) {
@@ -162,3 +162,15 @@ function vhostof (req, regexp) {
162162
163163 return obj
164164}
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