Sha256: 9fe717f862c3a9d9db92429eb9b6b5d475ed8a01879b1f3d54df9bf6a7224e3e

Contents?: true

Size: 863 Bytes

Versions: 17

Compression:

Stored size: 863 Bytes

Contents

/*!
 * Connect - vhost
 * Copyright(c) 2010 Sencha Inc.
 * Copyright(c) 2011 TJ Holowaychuk
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var vhost = require('vhost');

/**
 * Vhost:
 *
 * See [vhost](https://github.com/expressjs/vhost)
 *
 * @param {String} hostname
 * @param {Server} server
 * @return {Function}
 * @api public
 */

module.exports = function(hostname, server) {
  if (typeof hostname === 'string') {
    // back-compat
    hostname = new RegExp('^' + hostname.replace(/[^*\w]/g, '\\$&').replace(/[*]/g, '(?:.*?)')  + '$', 'i');
  }

  if (typeof server !== 'function' && typeof server.emit === 'function') {
    // back-compat
    server = createEmitRequest(server);
  }

  return vhost(hostname, server);
};

function createEmitRequest(server) {
  return function emitRequest(req, res) {
    server.emit('request', req, res);
  };
}

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/vhost.js