newsletter fix

This commit is contained in:
nmemmert
2026-06-03 12:08:53 -04:00
parent e561bfa000
commit 4983524ea4
+3 -3
View File
@@ -4783,8 +4783,8 @@ app.post('/api/contact', contactRateLimit, async (req, res) => {
res.status(400).json({ message: 'First name is required.' })
return
}
if (!lastName || typeof lastName !== 'string' || lastName.trim().length < 1 || lastName.trim().length > 100) {
res.status(400).json({ message: 'Last name is required.' })
if (lastName !== undefined && lastName !== null && (typeof lastName !== 'string' || lastName.trim().length > 100)) {
res.status(400).json({ message: 'Last name is too long.' })
return
}
if (!email || typeof email !== 'string' || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim())) {
@@ -4802,7 +4802,7 @@ app.post('/api/contact', contactRateLimit, async (req, res) => {
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 trimmedMessage = message.trim()
const normalizedMessageType = normalizeMessageType(messageType)