impr: add more options to moderation page (#604)
* feat: allow filtering by community on modpage * feat: add arbitrary banning * temp * feat: combine reports on reports page * design: clarify report design * fix: update lang key for navbar moderation
This commit is contained in:
1 parent
5b8f9d15af
commit
412977a484
16 files changed
+621
-190
No files matched your search
@@ -186,3 +186,35 @@ export function escapeHtml(input: string): string {
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
export function fuzzySearch(text: string, pattern: string): number {
|
||||
const textLower = text.toLowerCase()
|
||||
const patternLower = pattern.toLowerCase()
|
||||
let score = 0
|
||||
let lastIndex = -1
|
||||
let consecutiveBonus = 0
|
||||
|
||||
for (let i = 0; i < patternLower.length; i++) {
|
||||
const index = textLower.indexOf(patternLower[i], lastIndex + 1)
|
||||
if (index === -1) return 0
|
||||
|
||||
score += 1
|
||||
if (index === lastIndex + 1) {
|
||||
consecutiveBonus++
|
||||
score += consecutiveBonus
|
||||
} else {
|
||||
consecutiveBonus = 0
|
||||
}
|
||||
|
||||
lastIndex = index
|
||||
}
|
||||
|
||||
// Bonus for matching start of words
|
||||
if (textLower.startsWith(patternLower)) {
|
||||
score += 2
|
||||
} else if (textLower.includes(' ' + patternLower)) {
|
||||
score += 1
|
||||
}
|
||||
|
||||
return score
|
||||
}
|
||||
Reference in new issue
Block a user