Skip to content

Commit

Permalink
Fixed regular expression for single-digit unread counts
Browse files Browse the repository at this point in the history
```
  (\d+[,]?\d+)
```
This pattern will fail for any inbox count with single digits, because it will be looking for two different instances of (1 or more) digits.  There are a few potential fixes for this, but I don't know which is the most correct.  I went with the simple case of making the second pattern be (0 or more) digits.  Some alternatives
```
([\d,]+)
```
This would match any combination of numbers and commas.
```
(\d+(?:,\d+)*)
```
I think that would match any list of comma-separated numbers.
  • Loading branch information
herrevilkitten authored and timche committed Oct 18, 2017
1 parent 3f00f3d commit de551ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (isAlreadyRunning) {
}

function updateBadge(title) {
const unreadCount = /^.+\s\((\d+[,]?\d+)\)/.exec(title)
const unreadCount = /^.+\s\((\d+[,]?\d*)\)/.exec(title)

app.dock.setBadge(unreadCount ? unreadCount[1] : '')
}
Expand Down

0 comments on commit de551ab

Please sign in to comment.