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:
parent
11979cbee0
commit
0724776ccb
@ -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', () => {
|
||||
|
@ -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)
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user