From 0adb2cf8dc2cff0684a52c22d54802fd4d807cd2 Mon Sep 17 00:00:00 2001 From: Danijel Micic Date: Mon, 15 Dec 2025 14:06:37 +1100 Subject: [PATCH] fix: Add automatic whitespace trimming for form inputs - Trim all form field values before submission - Prevents copy-paste whitespace issues - Applied to both regular and auto-discovery tests --- public/script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/script.js b/public/script.js index de853be..1104243 100644 --- a/public/script.js +++ b/public/script.js @@ -270,6 +270,13 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e const formData = new FormData(this); const data = Object.fromEntries(formData.entries()); + // Trim all string values to prevent copy-paste whitespace issues + Object.keys(data).forEach(key => { + if (typeof data[key] === 'string') { + data[key] = data[key].trim(); + } + }); + try { const response = await fetch('/api/test-smtp', { method: 'POST', @@ -365,6 +372,13 @@ document.getElementById('autoTestBtn').addEventListener('click', async function const formData = new FormData(form); const data = Object.fromEntries(formData.entries()); + // Trim all string values + Object.keys(data).forEach(key => { + if (typeof data[key] === 'string') { + data[key] = data[key].trim(); + } + }); + // Only need host, user, pass, from, to for auto test const autoTestData = { host: data.host,