Skip to content

Commit

Permalink
Fixed nums regex match (hrai#268)
Browse files Browse the repository at this point in the history
* cleanup

* cleanup
  • Loading branch information
hrai authored and Felix Wong committed Oct 15, 2024
1 parent f6c390e commit 87fbee6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
command_exists () {
command -v "$1" > /dev/null 2>&1 &
}

# Windows 10, Git Bash and Yarn workaround
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"nodemon": "^3.0.3",
"prettier": "^3.2.5",
"run-script-os": "^1.1.3",
"sinon": "^18.0.0",
"sinon": "^19.0.2",
"web-ext": "^8.2.0",
"web-ext-submit": "^7.8.0",
"webextension-polyfill": "^0.12.0",
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function setKeyValue(keyValueName, value) {
}

export function shouldCapitalise(text) {
const multilineRegex = /\s*\n+\s*\w$/;
const multilineRegex = /\s*\n+\s*[a-z]$/;
let matches = multilineRegex.test(text);

//console.log("matches:" + matches);
Expand All @@ -173,7 +173,7 @@ export function shouldCapitalise(text) {
return true;
}

const sentenceRegex = /\w+\s*\W?([.?!])+\s+\w$/;
const sentenceRegex = /\w+\s*\W?([.?!])+\s+[a-z]$/;
matches = sentenceRegex.test(text);

if (!matches) {
Expand Down
5 changes: 5 additions & 0 deletions test/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ describe('util file tests', function () {
expect(utils.shouldCapitalise(' k ')).toBe(false);
expect(utils.shouldCapitalise(' k ')).toBe(false);
expect(utils.shouldCapitalise(' ')).toBe(false);
expect(utils.shouldCapitalise(' 1')).toBe(false);
expect(utils.shouldCapitalise('this is <war>? 1')).toBe(false);

expect(utils.shouldCapitalise('?')).toBe(true);
expect(utils.shouldCapitalise('!')).toBe(true);
Expand All @@ -97,6 +99,9 @@ describe('util file tests', function () {
expect(utils.shouldCapitalise('war? lasting \n peace \n\n k')).toBe(
true
);

expect(utils.shouldCapitalise('war? \n\n 1')).toBe(false);
expect(utils.shouldCapitalise('war? \n\n 12')).toBe(false);
});

test('shouldCapitalise_singleChar', () => {
Expand Down

0 comments on commit 87fbee6

Please sign in to comment.