Skip to content

Commit

Permalink
Merge pull request #40 from issue-ops/casing
Browse files Browse the repository at this point in the history
Fix selected checkbox case check
  • Loading branch information
ncalteen authored Jan 1, 2024
2 parents 99609d6 + b9dd220 commit aeb7540
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion __tests__/fixtures/example/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ thing.toString()
### Is the Thing Useful?

- [ ] Yes
- [x] Sometimes
- [X] Sometimes
- [ ] No

### Read Team
Expand Down
7 changes: 4 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parser",
"description": "Convert issue form responses to JSON",
"version": "0.2.2",
"version": "0.2.3",
"author": "Nick Alteen <[email protected]>",
"homepage": "https://github.com/issue-ops/parser#readme",
"repository": {
Expand Down
7 changes: 4 additions & 3 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function formatValue(
: value.split(/, */)
}
case 'checkboxes': {
const checkedExp: RegExp = /^-\s\[x\]\s/im
const checkboxes: Checkboxes = {
selected: [],
unselected: []
Expand All @@ -65,9 +66,9 @@ export function formatValue(
// Add unchecked items to unselected
for (let line of value.split('\n')) {
line = line.trim()
line.startsWith('- [x] ')
? checkboxes.selected.push(line.replace('- [x] ', ''))
: checkboxes.unselected.push(line.replace('- [ ] ', ''))
checkedExp.test(line)
? checkboxes.selected.push(line.replace(/-\s\[x\]\s/i, ''))
: checkboxes.unselected.push(line.replace(/-\s\[\s\]\s/i, ''))
}

return checkboxes
Expand Down

0 comments on commit aeb7540

Please sign in to comment.