mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 14:07:09 +03:00
Added [] return rather than 404 for no segments with matching hash
This commit is contained in:
@@ -20,10 +20,10 @@ module.exports = async function (req, res) {
|
|||||||
|
|
||||||
// Get all video id's that match hash prefix
|
// Get all video id's that match hash prefix
|
||||||
const videoIds = db.prepare('all', 'SELECT DISTINCT videoId, hashedVideoID from sponsorTimes WHERE hashedVideoID LIKE ?', [hashPrefix+'%']);
|
const videoIds = db.prepare('all', 'SELECT DISTINCT videoId, hashedVideoID from sponsorTimes WHERE hashedVideoID LIKE ?', [hashPrefix+'%']);
|
||||||
if (videoIds.length === 0) {
|
/*if (videoIds.length === 0) {
|
||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
let segments = videoIds.map((video) => {
|
let segments = videoIds.map((video) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe('getSegmentsByHash', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to get a 404 if no videos', (done) => {
|
/*it('Should be able to get a 404 if no videos', (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
+ '/api/skipSegments/11111?categories=["shilling"]', null,
|
+ '/api/skipSegments/11111?categories=["shilling"]', null,
|
||||||
(err, res, body) => {
|
(err, res, body) => {
|
||||||
@@ -50,8 +50,23 @@ describe('getSegmentsByHash', () => {
|
|||||||
done(); // pass
|
done(); // pass
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});*/
|
||||||
|
|
||||||
|
it('Should be able to get an emptry array if no videos', (done) => {
|
||||||
|
request.get(utils.getbaseURL()
|
||||||
|
+ '/api/skipSegments/11111?categories=["shilling"]', null,
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done("Couldn't call endpoint");
|
||||||
|
else if (res.statusCode !== 200) done("non 200 status code, was " + res.statusCode);
|
||||||
|
else {
|
||||||
|
if (JSON.parse(body).length === 0) done(); // pass
|
||||||
|
else done("non empty array returned");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Should return 400 prefix too short', (done) => {
|
it('Should return 400 prefix too short', (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
+ '/api/skipSegments/11?categories=["shilling"]', null,
|
+ '/api/skipSegments/11?categories=["shilling"]', null,
|
||||||
|
|||||||
Reference in New Issue
Block a user