fix: #806, allow partial word matches using 'like' operator

This commit is contained in:
James
2022-07-25 16:48:45 -04:00
parent 9589f0798f
commit c96985be0c

View File

@@ -98,7 +98,7 @@ export const sanitizeQueryValue = (schemaType: SchemaType, path: string, operato
if (operator === 'like' && typeof formattedValue === 'string') {
const words = formattedValue.split(' ');
const regex = words.reduce((pattern, word, i) => {
return `${pattern}(?=.*\\b${word}\\b)${i + 1 === words.length ? '.+' : ''}`;
return `${pattern}(?=.*\\b${word}.*\\b)${i + 1 === words.length ? '.+' : ''}`;
}, '');
formattedValue = { $regex: new RegExp(regex), $options: 'i' };