fix: don't try to parse date numbers with letters around them

This commit is contained in:
kolaente 2022-01-30 12:37:14 +01:00
parent b3697cb9bf
commit 931941359b
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 8 additions and 2 deletions

View file

@ -288,7 +288,7 @@ const getDateFromWeekday = (text: string): dateFoundResult => {
} }
const getDayFromText = (text: string) => { const getDayFromText = (text: string) => {
const matcher = /(([1-2][0-9])|(3[01])|(0?[1-9]))(st|nd|rd|th|\.)/ig const matcher = /($| )(([1-2][0-9])|(3[01])|(0?[1-9]))(st|nd|rd|th|\.)($| )/ig
const results = matcher.exec(text) const results = matcher.exec(text)
if (results === null) { if (results === null) {
return { return {

View file

@ -242,6 +242,12 @@ describe('Parse Task Text', () => {
expect(result.text).toBe('Lorem Ipsum github') expect(result.text).toBe('Lorem Ipsum github')
expect(result.date).toBeNull() expect(result.date).toBeNull()
}) })
it('should not recognize date number with no spacing around them', () => {
const result = parseTaskText('Lorem Ispum v1.1.1')
expect(result.text).toBe('Lorem Ispum v1.1.1')
expect(result.date).toBeNull()
})
describe('Parse weekdays', () => { describe('Parse weekdays', () => {