fix: #806, allow partial word matches using 'like' operator
This commit is contained in:
@@ -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' };
|
||||
|
||||
Reference in New Issue
Block a user