Fix: Make backend data parsing more robust
Publish Docker image / build-and-push (push) Successful in 1m28s
Publish Docker image / build-and-push (push) Successful in 1m28s
This commit is contained in:
+5
-1
@@ -37,7 +37,11 @@ app.get('/api/domains', async (req, res) => {
|
|||||||
const data = await s3.getObject(params).promise();
|
const data = await s3.getObject(params).promise();
|
||||||
const fileContent = data.Body.toString('utf-8');
|
const fileContent = data.Body.toString('utf-8');
|
||||||
const domains = fileContent.split('\n').filter(line => line).map(line => {
|
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 };
|
return { domain, type };
|
||||||
});
|
});
|
||||||
res.json(domains);
|
res.json(domains);
|
||||||
|
|||||||
Reference in New Issue
Block a user