From b2877dd36c75e08cc3547e114371aaf640427a10 Mon Sep 17 00:00:00 2001 From: iamkiddy Date: Wed, 26 Nov 2025 11:44:16 +0000 Subject: [PATCH] Improve error handling in createAppointment function by using [\s\S] regex for better compatibility in parsing HTML error messages. --- lib/actions/appointments.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/actions/appointments.ts b/lib/actions/appointments.ts index b094928..11badc6 100644 --- a/lib/actions/appointments.ts +++ b/lib/actions/appointments.ts @@ -147,9 +147,10 @@ export async function createAppointment( let errorMessage = `Server error (${response.status}): ${response.statusText || 'Internal Server Error'}`; // Try to find error details in HTML - const errorMatch = responseText.match(/]*>(.*?)<\/pre>/is) || - responseText.match(/]*>(.*?)<\/h1>/is) || - responseText.match(/]*>(.*?)<\/title>/is); + // Use [\s\S] instead of . with s flag for better compatibility + const errorMatch = responseText.match(/]*>([\s\S]*?)<\/pre>/i) || + responseText.match(/]*>([\s\S]*?)<\/h1>/i) || + responseText.match(/]*>([\s\S]*?)<\/title>/i); if (errorMatch && errorMatch[1]) { const htmlError = errorMatch[1].replace(/<[^>]*>/g, '').trim();