diff --git a/package.json b/package.json index 0da47d77..9ab35adb 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts", "cypress:open": "cypress open", "test:unit": "vitest run", + "test:unit-watch": "vitest watch", "test:frontend": "cypress run", "browserslist:update": "npx browserslist@latest --update-db" }, diff --git a/src/modules/parseTaskText.test.js b/src/modules/parseTaskText.test.js index 4b3ade21..19f3ba17 100644 --- a/src/modules/parseTaskText.test.js +++ b/src/modules/parseTaskText.test.js @@ -32,6 +32,13 @@ describe('Parse Task Text', () => { expect(result.assignees).toHaveLength(1) expect(result.assignees[0]).toBe('user') }) + + it('should ignore email addresses', () => { + const text = 'Lorem Ipsum email@example.com' + const result = parseTaskText(text) + + expect(result.text).toBe(text) + }) describe('Date Parsing', () => { it('should not return any date if none was provided', () => { diff --git a/src/modules/parseTaskText.ts b/src/modules/parseTaskText.ts index 30434f00..80c33e3d 100644 --- a/src/modules/parseTaskText.ts +++ b/src/modules/parseTaskText.ts @@ -117,23 +117,30 @@ export const parseTaskText = (text: string, prefixesMode: PrefixMode = PrefixMod const getItemsFromPrefix = (text: string, prefix: string): string[] => { const items: string[] = [] - const itemParts = text.split(prefix) + const itemParts = text.split(' ' + prefix) + if (text.startsWith(prefix)) { + const firstItem = text.split(prefix)[1] + itemParts.unshift(firstItem) + } + itemParts.forEach((p, index) => { // First part contains the rest if (index < 1) { return } - let labelText + p = p.replace(prefix, '') + + let itemText if (p.charAt(0) === '\'') { - labelText = p.split('\'')[1] + itemText = p.split('\'')[1] } else if (p.charAt(0) === '"') { - labelText = p.split('"')[1] + itemText = p.split('"')[1] } else { // Only until the next space - labelText = p.split(' ')[0] + itemText = p.split(' ')[0] } - items.push(labelText) + items.push(itemText) }) return Array.from(new Set(items))