Handling undefined hostname

This commit is contained in:
MrFry 2020-04-13 08:59:51 +02:00
parent e3fecd61d0
commit 3aa36520d4

View file

@ -11,7 +11,12 @@ module.exports = function (options) {
} }
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
const hostname = req.hostname.replace('www.', '').split('.')[0] let hostname = 'UNDEF'
if (req.hostname) {
hostname = req.hostname.replace('www.', '').split('.')[0]
} else {
logger.Log('Hostname is undefined!', logger.GetColor('redbg'))
}
// fixme: regexp includes checking // fixme: regexp includes checking
const hasLoggableKeyword = loggableKeywords && loggableKeywords.some((x) => { const hasLoggableKeyword = loggableKeywords && loggableKeywords.some((x) => {