Skip to content

Commit

Permalink
Merge pull request #1287 from nebbers1111/master
Browse files Browse the repository at this point in the history
Fixed regex to stop [anytingx] being counted as a checkmark
  • Loading branch information
kazup01 committed Dec 14, 2017
2 parents eda1f11 + 6431a82 commit 7afe3d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/lib/getTodoStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\] ./)) {
Expand Down
7 changes: 6 additions & 1 deletion tests/lib/get-todo-status-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 7afe3d5

Please sign in to comment.