diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index 09e3654..12ff3f0 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -302,7 +302,7 @@ async function checkUserActiveWarning(userID: string): Promise { function checkInvalidFields(videoID: VideoID, userID: UserID, segments: IncomingSegment[]): CheckResult { const invalidFields = []; const errors = []; - if (typeof videoID !== "string") { + if (typeof videoID !== "string" || videoID?.length == 0) { invalidFields.push("videoID"); } if (typeof userID !== "string" || userID?.length < 30) { diff --git a/test/cases/postSkipSegments.ts b/test/cases/postSkipSegments.ts index 6d849d7..c891e51 100644 --- a/test/cases/postSkipSegments.ts +++ b/test/cases/postSkipSegments.ts @@ -1084,4 +1084,20 @@ describe("postSkipSegments", () => { }) .catch(err => done(err)); }); + + it("Should return 400 if videoID is empty", (done) => { + const videoID = null as string; + postSkipSegmentParam({ + videoID, + startTime: 1, + endTime: 5, + category: "sponsor", + userID: submitUserTwo + }) + .then(res => { + assert.strictEqual(res.status, 400); + done(); + }) + .catch(err => done(err)); + }); });