Redirect with same protocol as request

Try using // instead of explicit protocol
This commit is contained in:
Phoenix Eliot 2016-09-09 14:00:02 -07:00
parent bbe4a0540d
commit c24e81aebb

View file

@ -62,9 +62,9 @@ setupDomainFilterMiddleware = (app) ->
domainRegex = new RegExp("(.*\.)?(#{config.mainHostname}|#{config.unsafeContentHostname})")
domainPrefix = req.host.match(domainRegex)?[1] or ''
if _.any(unsafePaths, (pathRegex) -> pathRegex.test(req.path)) and (req.host isnt domainPrefix + config.unsafeContentHostname)
res.redirect('http://' + domainPrefix + config.unsafeContentHostname + req.path)
res.redirect('//' + domainPrefix + config.unsafeContentHostname + req.path)
else if not _.any(unsafePaths, (pathRegex) -> pathRegex.test(req.path)) and req.host is domainPrefix + config.unsafeContentHostname
res.redirect('http://' + domainPrefix + config.mainHostname + req.path)
res.redirect('//' + domainPrefix + config.mainHostname + req.path)
else
next()