newsletter fix
This commit is contained in:
@@ -4783,8 +4783,8 @@ app.post('/api/contact', contactRateLimit, async (req, res) => {
|
|||||||
res.status(400).json({ message: 'First name is required.' })
|
res.status(400).json({ message: 'First name is required.' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!lastName || typeof lastName !== 'string' || lastName.trim().length < 1 || lastName.trim().length > 100) {
|
if (lastName !== undefined && lastName !== null && (typeof lastName !== 'string' || lastName.trim().length > 100)) {
|
||||||
res.status(400).json({ message: 'Last name is required.' })
|
res.status(400).json({ message: 'Last name is too long.' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!email || typeof email !== 'string' || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim())) {
|
if (!email || typeof email !== 'string' || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim())) {
|
||||||
@@ -4802,7 +4802,7 @@ app.post('/api/contact', contactRateLimit, async (req, res) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const trimmedName = `${firstName.trim()} ${lastName.trim()}`.trim()
|
const trimmedName = [firstName.trim(), typeof lastName === 'string' ? lastName.trim() : ''].filter(Boolean).join(' ')
|
||||||
const trimmedEmail = email.trim()
|
const trimmedEmail = email.trim()
|
||||||
const trimmedMessage = message.trim()
|
const trimmedMessage = message.trim()
|
||||||
const normalizedMessageType = normalizeMessageType(messageType)
|
const normalizedMessageType = normalizeMessageType(messageType)
|
||||||
|
|||||||
Reference in New Issue
Block a user