var url = require("url")

module.exports = function(req, next){
  req.ssl = null
  var u   = url.parse(req.domain)

  if (u.protocol !== null) {
    if (u.protocol == "https:") req.ssl = true
    if (u.protocol == "http:") req.ssl = false
    req.domain = u.hostname
  }

  next()
}