fix(quick add magic): don't replace the prefix in every occurrence when it is present in the matched part

This commit is contained in:
kolaente
2023-06-05 14:09:19 +00:00
committed by konrad
parent 11979cbee0
commit 0724776ccb
2 changed files with 13 additions and 3 deletions
+8
View File
@@ -691,6 +691,14 @@ describe('Parse Task Text', () => {
expect(result.assignees).toHaveLength(1)
expect(result.assignees[0]).toBe('today')
})
it('should recognize an email address', () => {
const text = 'Lorem Ipsum @email@example.com'
const result = parseTaskText(text)
expect(result.text).toBe('Lorem Ipsum @email@example.com')
expect(result.assignees).toHaveLength(1)
expect(result.assignees[0]).toBe('email@example.com')
})
})
describe('Recurring Dates', () => {
+5 -3
View File
@@ -109,7 +109,9 @@ const getItemsFromPrefix = (text: string, prefix: string): string[] => {
return
}
p = p.replace(prefix, '')
if (p.substring(0, 1) === prefix) {
p = p.substring(1)
}
let itemText
if (p.charAt(0) === '\'') {
@@ -120,8 +122,8 @@ const getItemsFromPrefix = (text: string, prefix: string): string[] => {
// Only until the next space
itemText = p.split(' ')[0]
}
if(itemText !== '') {
if (itemText !== '') {
items.push(itemText)
}
})