Keyword validation
This commit is contained in:
parent
b587ee084c
commit
085e351245
@ -175,10 +175,16 @@ function loadDb(params) {
|
||||
}
|
||||
|
||||
function addKeyword(query, callback) {
|
||||
var keyword = (query.keyword || '').toLowerCase();
|
||||
if (!/^[a-zA-Z0-9]+$/.test(keyword)) {
|
||||
callback({
|
||||
keyword: keyword,
|
||||
success: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
getKeywords(function(keywords) {
|
||||
var keyword = query.keyword.toLowerCase();
|
||||
var features = combine(keywords, query.params);
|
||||
|
||||
var values = [
|
||||
keyword,
|
||||
features.food || 0.0,
|
||||
@ -195,6 +201,7 @@ function addKeyword(query, callback) {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeKeyword(query, callback) {
|
||||
connection.query('DELETE FROM keywords WHERE name=? AND name NOT IN (SELECT name FROM presets)', [query.keyword], function(err, fields) {
|
||||
|
Loading…
Reference in New Issue
Block a user