lib/middleware.js
function () {
    return function (req, res, next) {
      var apphost = config.url.host,
          outputHost = undefsafe(config, 'security.preview'),
          host = req.header('Host', ''),
          offset = host.indexOf(apphost);

      if (host === outputHost) {
        offset = host.indexOf(outputHost);
      }

      if (offset > 0) {
        // Slice the host from the subdomain and subtract 1 for
        // trailing . on the subdomain.
        req.subdomain = host.slice(0, offset - 1);
      }
      next();
    };
  }
function () {
    return function (req, res, next) {
      var apphost = config.url.host,
          outputHost = undefsafe(config, 'security.preview'),
          host = req.header('Host', ''),
          offset = host.indexOf(apphost);

      if (host === outputHost) {
        offset = host.indexOf(outputHost);
      }

      if (offset > 0) {
        // Slice the host from the subdomain and subtract 1 for
        // trailing . on the subdomain.
        req.subdomain = host.slice(0, offset - 1);
      }
      next();
    };
  }
function ( ) { return function ( req , res , next ) { var apphost = config . url . host , outputHost = undefsafe ( config , 'security.preview' ) , host = req . header ( 'Host' , '' ) , offset = host . indexOf ( apphost ) ; if ( host === outputHost ) { offset = host . indexOf ( outputHost ) ; } if ( offset > 0 ) { // Slice the host from the subdomain and subtract 1 for // trailing . on the subdomain. req . subdomain = host . slice ( 0 , offset - 1 ) ; } next ( ) ; } ; }
Checks for a subdomain in the current url, if found it sets the req.subdomain property. This supports existing behaviour that allows subdomains to load custom config files.
Checks for a subdomain in the current url if found it sets the req . subdomain property . This supports existing behaviour that allows subdomains to load custom config files .