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
This commit is contained in:
Danijel Micic
2025-12-15 14:06:37 +11:00
parent 688c2ba52c
commit 0adb2cf8dc

View File

@@ -270,6 +270,13 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e
const formData = new FormData(this); const formData = new FormData(this);
const data = Object.fromEntries(formData.entries()); 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 { try {
const response = await fetch('/api/test-smtp', { const response = await fetch('/api/test-smtp', {
method: 'POST', method: 'POST',
@@ -365,6 +372,13 @@ document.getElementById('autoTestBtn').addEventListener('click', async function
const formData = new FormData(form); const formData = new FormData(form);
const data = Object.fromEntries(formData.entries()); 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 // Only need host, user, pass, from, to for auto test
const autoTestData = { const autoTestData = {
host: data.host, host: data.host,