Tidy up code to normalize text, extract text helpers
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
export function isMultiLineString(string) {
|
||||
return /\r|\n/.test(string)
|
||||
}
|
||||
|
||||
export function normalizeFilteredText(string) {
|
||||
return string
|
||||
.toLowerCase()
|
||||
.normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove diacritics
|
||||
}
|
||||
|
||||
export function filterMatches(text, potentialMatch) {
|
||||
return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user