Initial Product release
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
function parseJsonSafe(value) {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (_error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function readFormArray(body, key) {
|
||||
if (Array.isArray(body[key])) {
|
||||
return body[key];
|
||||
}
|
||||
if (body[key] === undefined) {
|
||||
return [];
|
||||
}
|
||||
return [body[key]];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseJsonSafe,
|
||||
readFormArray
|
||||
};
|
||||
Reference in New Issue
Block a user