You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
var sanitizeAll = require('../sanitiser/sanitizeAll'),
|
|
|
|
sanitizers = {
|
|
|
|
text: require('../sanitiser/_text_addressit')
|
|
|
|
};
|
|
|
|
|
|
|
|
var sanitize = function(req, cb) { sanitizeAll(req, sanitizers, cb); };
|
|
|
|
|
|
|
|
// middleware
|
|
|
|
module.exports.middleware = function( req, res, next ){
|
|
|
|
// if res.data already has results then don't call the _text_autocomplete sanitiser
|
|
|
|
// this has been put into place for when the libpostal integration way of querying
|
|
|
|
// ES doesn't return anything and we want to fallback to the old logic
|
|
|
|
if (res && res.hasOwnProperty('data') && res.data.length > 0) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
|
|
|
sanitize( req, function( err, clean ){
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|