Fix: Make backend data parsing more robust
Publish Docker image / build-and-push (push) Successful in 1m28s

This commit is contained in:
2025-07-07 14:36:43 +07:00
parent 7bf55bd1d2
commit 92684736f9
+5 -1
View File
@@ -37,7 +37,11 @@ app.get('/api/domains', async (req, res) => {
const data = await s3.getObject(params).promise();
const fileContent = data.Body.toString('utf-8');
const domains = fileContent.split('\n').filter(line => line).map(line => {
const [domain, type] = line.split(' ');
// Trim the line to remove any leading/trailing whitespace, including \r
// And split by any whitespace to be more robust
const parts = line.trim().split(/\s+/);
const domain = parts[0] || '';
const type = parts[1] || '';
return { domain, type };
});
res.json(domains);