Comparing version 2.0.0 to 3.0.0
@@ -0,1 +1,6 @@ | ||
3.0.0 / 2014-08-29 | ||
================== | ||
* Remove support for sub-http servers; use the `handle` function | ||
2.0.0 / 2014-06-08 | ||
@@ -2,0 +7,0 @@ ================== |
51
index.js
@@ -1,7 +0,5 @@ | ||
/*! | ||
* vhost | ||
* Copyright(c) 2010 Sencha Inc. | ||
* Copyright(c) 2011 TJ Holowaychuk | ||
* Copyright(c) 2014 Jonathan Ong | ||
* Copyright(c) 2014 Douglas Christopher Wilson | ||
* MIT Licensed | ||
@@ -11,16 +9,6 @@ */ | ||
/** | ||
* vhost: | ||
* Create a vhost middleware. | ||
* | ||
* Setup vhost for the given `hostname` and `server`. | ||
* | ||
* connect() | ||
* .use(connect.vhost('foo.com', fooApp)) | ||
* .use(connect.vhost('bar.com', barApp)) | ||
* .use(connect.vhost('*.com', mainApp)) | ||
* | ||
* The `server` may be a Connect server, a callable function, | ||
* or a regular Node `http.Server`. | ||
* | ||
* @param {string|RegExp} hostname | ||
* @param {function|Server} server | ||
* @param {function} handle | ||
* @return {Function} | ||
@@ -30,3 +18,3 @@ * @api public | ||
module.exports = function vhost(hostname, server){ | ||
module.exports = function vhost(hostname, handle) { | ||
if (!hostname) { | ||
@@ -36,8 +24,9 @@ throw new TypeError('argument hostname is required') | ||
if (!server) { | ||
throw new Error('argument server is required') | ||
if (!handle) { | ||
throw new TypeError('argument handle is required') | ||
} | ||
// create a handle for the server | ||
var handle = createHandle(server) | ||
if (typeof handle !== 'function') { | ||
throw new TypeError('argument handle must be a function') | ||
} | ||
@@ -63,24 +52,2 @@ // create regular expression for hostname | ||
/** | ||
* Create handle to server. | ||
* | ||
* @param {function|Server} server | ||
* @return {function} | ||
* @api private | ||
*/ | ||
function createHandle(server){ | ||
if (typeof server === 'function') { | ||
// callable servers are the handle | ||
return server | ||
} else if (typeof server.emit === 'function') { | ||
// emit request event on server | ||
return function handle(req, res) { | ||
server.emit('request', req, res) | ||
} | ||
} | ||
throw new TypeError('argument server is unsupported') | ||
} | ||
/** | ||
* Get hostname of request. | ||
@@ -87,0 +54,0 @@ * |
{ | ||
"name": "vhost", | ||
"description": "virtual domain hosting", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)", | ||
@@ -12,7 +12,12 @@ "contributors": [ | ||
"devDependencies": { | ||
"istanbul": "0.2.10", | ||
"mocha": "~1.20.1", | ||
"istanbul": "0.3.0", | ||
"mocha": "~1.21.4", | ||
"should": "~4.0.1", | ||
"supertest": "~0.13.0" | ||
}, | ||
"files": [ | ||
"LICENSE", | ||
"HISTORY.md", | ||
"index.js" | ||
], | ||
"engines": { | ||
@@ -22,6 +27,6 @@ "node": ">= 0.8.0" | ||
"scripts": { | ||
"test": "mocha --reporter dot test/", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/", | ||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/" | ||
"test": "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/" | ||
} | ||
} |
# vhost | ||
[![NPM version](https://badge.fury.io/js/vhost.svg)](http://badge.fury.io/js/vhost) | ||
[![Build Status](https://travis-ci.org/expressjs/vhost.svg?branch=master)](https://travis-ci.org/expressjs/vhost) | ||
[![Coverage Status](https://img.shields.io/coveralls/expressjs/vhost.svg?branch=master)](https://coveralls.io/r/expressjs/vhost) | ||
[![NPM Version][npm-image]][npm-url] | ||
[![NPM Downloads][downloads-image]][downloads-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Test Coverage][coveralls-image]][coveralls-url] | ||
[![Gratipay][gratipay-image]][gratipay-url] | ||
Previously `connect.vhost()`. | ||
## Install | ||
@@ -91,3 +91,3 @@ | ||
userapp.user(function(req, res, next){ | ||
userapp.use(function(req, res, next){ | ||
var username = req.vhost[0] // username is the "*" | ||
@@ -111,3 +111,3 @@ | ||
// listen on all subdomains for user pages | ||
app.use(vhost('*.userpages.local', userapp) | ||
app.use(vhost('*.userpages.local', userapp)) | ||
@@ -119,22 +119,13 @@ app.listen(3000) | ||
The MIT License (MIT) | ||
[MIT](LICENSE) | ||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
[npm-image]: https://img.shields.io/npm/v/vhost.svg?style=flat | ||
[npm-url]: https://npmjs.org/package/vhost | ||
[travis-image]: https://img.shields.io/travis/expressjs/vhost.svg?style=flat | ||
[travis-url]: https://travis-ci.org/expressjs/vhost | ||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/vhost.svg?style=flat | ||
[coveralls-url]: https://coveralls.io/r/expressjs/vhost | ||
[downloads-image]: https://img.shields.io/npm/dm/vhost.svg?style=flat | ||
[downloads-url]: https://npmjs.org/package/vhost | ||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat | ||
[gratipay-url]: https://gratipay.com/dougwilson/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
8589
5
116
129