1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Fixed regex to stop [anytingx] being counted as a checkmark

This commit is contained in:
Ben Coleman
2017-12-12 13:34:37 +00:00
parent 4c3e62efad
commit 48fd1d11e2
2 changed files with 7 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ export function getTodoStatus (content) {
splitted.forEach((line) => {
const trimmedLine = line.trim()
if (trimmedLine.match(/^[\+\-\*] \[\s|x\] ./)) {
if (trimmedLine.match(/^[\+\-\*] \[(\s|x)\] ./)) {
numberOfTodo++
}
if (trimmedLine.match(/^[\+\-\*] \[x\] ./)) {

View File

@@ -11,7 +11,12 @@ test('getTodoStatus should return a correct hash object', t => {
['- [ ] a\n', { total: 1, completed: 0 }],
['- [ ] a\n- [x] a\n', { total: 2, completed: 1 }],
['+ [ ] a\n', { total: 1, completed: 0 }],
['+ [ ] a\n+ [x] a\n', { total: 2, completed: 1 }]
['+ [ ] a\n+ [x] a\n', { total: 2, completed: 1 }],
['+ [ ] a\n+ [testx] a\n', { total: 1, completed: 0 }],
['+ [ ] a\n+ [xtest] a\n', { total: 1, completed: 0 }],
['+ [ ] a\n+ foo[x]bar a\n', { total: 1, completed: 0 }],
['+ [ ] a\n+ foo[x] bar a\n', { total: 1, completed: 0 }],
['+ [ ] a\n+ foo [x]bar a\n', { total: 1, completed: 0 }]
]
testCases.forEach(testCase => {