Skip to content

Commit

Permalink
applied fix for numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
hrai committed Oct 12, 2024
1 parent 046187a commit 550e4ec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

yarn lint-staged
5 changes: 2 additions & 3 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"
# . "$(dirname "$0")/common.sh"

# Bash sets the BASH environment variable, so if it is not set, then we
# are running in a different shell, so manually run ourselves in BASH.
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 550e4ec

Please sign in to comment.