fix: don't try to parse date numbers with letters around them
This commit is contained in:
parent
b3697cb9bf
commit
931941359b
2 changed files with 8 additions and 2 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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', () => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue