Skip to content

Commit

Permalink
Add http2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
sogaani committed Aug 1, 2018
1 parent 3bed452 commit 088803d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ node_js:
- "5.12"
- "6.12"
- "7.10"
- "8.9"
- "9.3"
- "8.11"
- "10.7"
sudo: false
cache:
directories:
Expand All @@ -23,6 +23,7 @@ before_install:
# Setup Node.js version-specific dependencies
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)"
- "test -z $(echo $HTTP2_TEST) || npm install --only=dev https://github.com/sogaani/supertest.git#http2"

# Update Node.js modules
- "test ! -d node_modules || npm prune"
Expand All @@ -34,3 +35,10 @@ script:
- "test -z $(npm -ps ls eslint ) || npm run-script lint"
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"

matrix:
include:
- node_js: "8.11"
env: HTTP2_TEST=1
- node_js: "10.7"
env: HTTP2_TEST=1
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function vhost (hostname, handle) {
*/

function hostnameof (req) {
var host = req.host
var host = req.headers.host ? req.headers.host : req.headers[':authority']

if (!host) {
return
Expand Down Expand Up @@ -137,7 +137,7 @@ function hostregexp (val) {
*/

function vhostof (req, regexp) {
var host = req.host
var host = req.headers.host ? req.headers.host : req.headers[':authority']
var hostname = hostnameof(req)

if (!hostname) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-http2": "HTTP2_TEST=1 mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
}
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ var http = require('http')
var request = require('supertest')
var vhost = require('..')

if (process.env.HTTP2_TEST) {
request.http2 = true;
http = require('http2')
}

describe('vhost(hostname, server)', function () {
it('should route by Host', function (done) {
var vhosts = []
Expand Down

0 comments on commit 088803d

Please sign in to comment.