Skip to content

Commit 7afe3d5

Browse files
authored
Merge pull request #1287 from nebbers1111/master
Fixed regex to stop [anytingx] being counted as a checkmark
2 parents eda1f11 + 6431a82 commit 7afe3d5

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

browser/lib/getTodoStatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function getTodoStatus (content) {
55

66
splitted.forEach((line) => {
77
const trimmedLine = line.trim()
8-
if (trimmedLine.match(/^[\+\-\*] \[\s|x\] ./)) {
8+
if (trimmedLine.match(/^[\+\-\*] \[(\s|x)\] ./)) {
99
numberOfTodo++
1010
}
1111
if (trimmedLine.match(/^[\+\-\*] \[x\] ./)) {

tests/lib/get-todo-status-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ test('getTodoStatus should return a correct hash object', t => {
1111
['- [ ] a\n', { total: 1, completed: 0 }],
1212
['- [ ] a\n- [x] a\n', { total: 2, completed: 1 }],
1313
['+ [ ] a\n', { total: 1, completed: 0 }],
14-
['+ [ ] a\n+ [x] a\n', { total: 2, completed: 1 }]
14+
['+ [ ] a\n+ [x] a\n', { total: 2, completed: 1 }],
15+
['+ [ ] a\n+ [testx] a\n', { total: 1, completed: 0 }],
16+
['+ [ ] a\n+ [xtest] a\n', { total: 1, completed: 0 }],
17+
['+ [ ] a\n+ foo[x]bar a\n', { total: 1, completed: 0 }],
18+
['+ [ ] a\n+ foo[x] bar a\n', { total: 1, completed: 0 }],
19+
['+ [ ] a\n+ foo [x]bar a\n', { total: 1, completed: 0 }]
1520
]
1621

1722
testCases.forEach(testCase => {

0 commit comments

Comments
 (0)