Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Passed into power-select component for customized searching.
// Returns results if match in node, root, or parent title
const fields = [
'title',
'root.title',
'parent.title',
];
const sanitizedTerm = stripDiacritics(term).toLowerCase();
for (const field of fields) {
const fieldValue = node.get(field) || '';
if (!fieldValue) continue;
const sanitizedValue = stripDiacritics(fieldValue).toLowerCase();
if (sanitizedValue.includes(sanitizedTerm)) {
return 1;
}
}
return -1;
},
});
titleMatcher(node, term) {
// Passed into power-select component for customized searching.
// Returns results if match in node, root, or parent title
const fields = [
'title',
'root.title',
'parent.title',
];
const sanitizedTerm = stripDiacritics(term).toLowerCase();
for (const field of fields) {
const fieldValue = node.get(field) || '';
if (!fieldValue) continue;
const sanitizedValue = stripDiacritics(fieldValue).toLowerCase();
if (sanitizedValue.includes(sanitizedTerm)) {
return 1;
}
}
return -1;
},
});
function stripAndLower(text: string): string {
return stripDiacritics(text).toLowerCase();
}