|
|
@@ -40,25 +40,20 @@ export default class TextRecordController {
|
|
|
}
|
|
|
|
|
|
private generatePasswordFromRecord(text?: string): string {
|
|
|
- if (!text || typeof text !== 'string') return ''
|
|
|
+ if (!text) return ''
|
|
|
const bullet = '•'
|
|
|
- const result: string[] = []
|
|
|
- const seenCounts = new Set<number>()
|
|
|
- const lines = text.split(/\r?\n/)
|
|
|
- for (const rawLine of lines) {
|
|
|
+ const chars: string[] = []
|
|
|
+ text.split(/\r?\n/).forEach((rawLine) => {
|
|
|
const line = rawLine.trim()
|
|
|
- if (line.length === 0) continue
|
|
|
- const lastChar = line.charAt(line.length - 1)
|
|
|
- if (lastChar === bullet) continue
|
|
|
- if (!/[A-Za-z0-9]/.test(lastChar)) continue
|
|
|
- const head = line.slice(0, -1)
|
|
|
- const allBullets = head.split('').every((c) => c === bullet)
|
|
|
- if (!allBullets) continue
|
|
|
- const bulletCount = head.length
|
|
|
- if (seenCounts.has(bulletCount)) continue
|
|
|
- seenCounts.add(bulletCount)
|
|
|
- result.push(lastChar)
|
|
|
- }
|
|
|
- return result.join('')
|
|
|
+ if (!line || line.endsWith(bullet)) return
|
|
|
+ const match = line.match(/^•*/)
|
|
|
+ const bullets = match ? match[0].length : 0
|
|
|
+ const content = line.slice(bullets)
|
|
|
+ if (!/^[A-Za-z0-9]+$/.test(content)) return
|
|
|
+ for (let i = 0; i < content.length; i++) {
|
|
|
+ chars[bullets + i] = content[i]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return chars.join('')
|
|
|
}
|
|
|
}
|