Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mauricionobrega/1da5b9291f94510402af2b0559884bbb to your computer and use it in GitHub Desktop.

Select an option

Save mauricionobrega/1da5b9291f94510402af2b0559884bbb to your computer and use it in GitHub Desktop.
function getSubdomain(h) {
var parts = h.split(".");
if(parts.length == 2) return "www";
return parts[0];
}
//later on...
exports.index = function(req, res) {
var subdomain = getSubdomain(req.headers.host);
res.render('index', { title: 'Express', subdomain:subdomain });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment