mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 14:38:47 +00:00
Enhancement: strip whitespace when checking JSON (#3706)
This commit is contained in:
parent
231e2408c3
commit
38c32233f6
1 changed files with 7 additions and 2 deletions
|
@ -10,10 +10,15 @@ export default function validateWidgetData(widget, endpoint, data) {
|
|||
try {
|
||||
dataParsed = JSON.parse(data);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
try {
|
||||
// try once more stripping whitespace
|
||||
dataParsed = JSON.parse(data.toString().replace(/\s/g, ""));
|
||||
} catch (e2) {
|
||||
error = e || e2;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataParsed && Object.entries(dataParsed).length) {
|
||||
const mappings = widgets[widget.type]?.mappings;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue