mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Merge pull request #251 from mchangrh/getSkipSegment-400
skipSegments return 400 if bad categories
This commit is contained in:
commit
47ddaaad7b
2 changed files with 11 additions and 1 deletions
|
@ -306,7 +306,9 @@ async function endpoint(req: Request, res: Response): Promise<void> {
|
|||
res.send(segments);
|
||||
}
|
||||
} catch (err) {
|
||||
res.status(500).send();
|
||||
if (err instanceof SyntaxError) {
|
||||
res.status(400).send("Categories parameter does not match format requirements.");
|
||||
} else res.status(500).send();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -227,6 +227,14 @@ describe('getSkipSegments', () => {
|
|||
.catch(err => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should return 400 if bad categories argument', (done: Done) => {
|
||||
fetch(getbaseURL() + "/api/skipSegments?videoID=testtesttest&categories=[not-quoted,not-quoted]")
|
||||
.then(res => {
|
||||
if (res.status !== 400) done("non 400 respone code: " + res.status);
|
||||
else done(); // pass
|
||||
})
|
||||
.catch(err => ("couldn't call endpoint"));
|
||||
});
|
||||
|
||||
it('Should be able send a comma in a query param', () => {
|
||||
fetch(getbaseURL() + "/api/skipSegments?videoID=testtesttest,test&category=sponsor")
|
||||
|
|
Loading…
Reference in a new issue