mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 16:37:12 +03:00
added underscore to category format check
This commit is contained in:
@@ -45,7 +45,7 @@ module.exports = (req, res) => {
|
|||||||
|
|
||||||
// get user categories not already submitted that match accepted format
|
// get user categories not already submitted that match accepted format
|
||||||
let categoriesToMark = categories.filter((category) => {
|
let categoriesToMark = categories.filter((category) => {
|
||||||
return !!category.match(/^[a-zA-Z]+$/);
|
return !!category.match(/^[_a-zA-Z]+$/);
|
||||||
}).filter((category) => {
|
}).filter((category) => {
|
||||||
return noSegmentList.indexOf(category) === -1;
|
return noSegmentList.indexOf(category) === -1;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -96,6 +96,90 @@ describe('noSegmentRecords', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should be able to submit categories with _ in the category', (done) => {
|
||||||
|
let json = {
|
||||||
|
videoID: 'underscore',
|
||||||
|
userID: 'VIPUser-noSegments',
|
||||||
|
categories: [
|
||||||
|
'word_word',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post(utils.getbaseURL()
|
||||||
|
+ "/api/postNoSegments", {json},
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done(err);
|
||||||
|
else if (res.statusCode === 200) {
|
||||||
|
let result = db.prepare('all', 'SELECT * FROM noSegments WHERE videoID = ?', ['underscore']);
|
||||||
|
if (result.length !== 1) {
|
||||||
|
console.log(result);
|
||||||
|
done("Expected 1 entrys in db, got " + result.length);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(body);
|
||||||
|
done("Status code was " + res.statusCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should be able to submit categories with upper and lower case in the category', (done) => {
|
||||||
|
let json = {
|
||||||
|
videoID: 'bothCases',
|
||||||
|
userID: 'VIPUser-noSegments',
|
||||||
|
categories: [
|
||||||
|
'wordWord',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post(utils.getbaseURL()
|
||||||
|
+ "/api/postNoSegments", {json},
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done(err);
|
||||||
|
else if (res.statusCode === 200) {
|
||||||
|
let result = db.prepare('all', 'SELECT * FROM noSegments WHERE videoID = ?', ['bothCases']);
|
||||||
|
if (result.length !== 1) {
|
||||||
|
console.log(result);
|
||||||
|
done("Expected 1 entrys in db, got " + result.length);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(body);
|
||||||
|
done("Status code was " + res.statusCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not be able to submit categories with $ in the category', (done) => {
|
||||||
|
let json = {
|
||||||
|
videoID: 'specialChar',
|
||||||
|
userID: 'VIPUser-noSegments',
|
||||||
|
categories: [
|
||||||
|
'word&word',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post(utils.getbaseURL()
|
||||||
|
+ "/api/postNoSegments", {json},
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done(err);
|
||||||
|
else if (res.statusCode === 200) {
|
||||||
|
let result = db.prepare('all', 'SELECT * FROM noSegments WHERE videoID = ?', ['specialChar']);
|
||||||
|
if (result.length !== 0) {
|
||||||
|
console.log(result);
|
||||||
|
done("Expected 0 entrys in db, got " + result.length);
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(body);
|
||||||
|
done("Status code was " + res.statusCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Should return 400 for missing params', (done) => {
|
it('Should return 400 for missing params', (done) => {
|
||||||
request.post(utils.getbaseURL()
|
request.post(utils.getbaseURL()
|
||||||
+ "/api/postNoSegments", {json: {}},
|
+ "/api/postNoSegments", {json: {}},
|
||||||
|
|||||||
Reference in New Issue
Block a user