Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function merge_query(queries, sep = ' ') {
if (queries.find(is_injection)) return SymbolInjection;
var query = reduce((res, query) => {
if (!query) return res;
if (query.text) res.text += (sep + query.text);
if (query.values) res.values.push(...query.values);
return res;
}, {
text: '',
values: []
}, queries);
query.text = query.text.replace(/\n/g, ' ').replace(/\s\s*/g, ' ').trim();
return query;
}