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.' })
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user