mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 21:13:39 +01:00
Enhancement: strip whitespace when checking JSON (#3706)
This commit is contained in:
parent
231e2408c3
commit
38c32233f6
@ -10,10 +10,15 @@ export default function validateWidgetData(widget, endpoint, data) {
|
|||||||
try {
|
try {
|
||||||
dataParsed = JSON.parse(data);
|
dataParsed = JSON.parse(data);
|
||||||
} catch (e) {
|
} 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;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dataParsed && Object.entries(dataParsed).length) {
|
if (dataParsed && Object.entries(dataParsed).length) {
|
||||||
const mappings = widgets[widget.type]?.mappings;
|
const mappings = widgets[widget.type]?.mappings;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user