Added undefined checking to accepted language

This commit is contained in:
Michael Schmatz 2015-03-20 17:47:17 -04:00
parent a9a3689e15
commit fcf52cfbf7

View file

@ -85,7 +85,7 @@ setupChinaRedirectMiddleware = (app) ->
geo = geoip.lookup(ip)
if geo?.country isnt "CN" then return false
firstAcceptedLanguage = req.acceptedLanguages[0]
isChinese = firstAcceptedLanguage.indexOf? "zh"
isChinese = firstAcceptedLanguage?.indexOf? "zh"
return isChinese? and isChinese isnt -1
else
return false #If the user is already redirected, don't redirect them!