mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-09-20 04:54:00 +02:00
add new missing field checks
This commit is contained in:
parent
7b818154dd
commit
967715ab3b
1 changed files with 16 additions and 5 deletions
|
@ -257,10 +257,21 @@ module.exports = async function postSkipSegments(req, res) {
|
|||
}];
|
||||
}
|
||||
|
||||
//check if all correct inputs are here and the length is 1 second or more
|
||||
if (videoID == undefined || userID == undefined || segments == undefined || segments.length < 1) {
|
||||
const invalidFields = [];
|
||||
if (typeof videoID !== 'string') {
|
||||
invalidFields.push('videoID');
|
||||
}
|
||||
if (typeof userID !== 'string') {
|
||||
invalidFields.push('userID');
|
||||
}
|
||||
if (!Array.isArray(segments) || segments.length < 1) {
|
||||
invalidFields.push('segments');
|
||||
}
|
||||
|
||||
if (invalidFields.length !== 0) {
|
||||
// invalid request
|
||||
res.status(400).send("Parameters are not valid");
|
||||
const fields = invalidFields.reduce((p, c, i) => p + (i !== 0 ? ', ' : '') + c, '');
|
||||
res.status(400).send(`No valid ${fields} field(s) provided`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue