Skip to content

Commit

Permalink
Bugfix/TS 496 Self assessment extraction word counts (#1275)
Browse files Browse the repository at this point in the history
* upgrade jac-kit to 4.1.51

* fix vulnerabilities

* upgrade jac-kit to 4.1.52

* update package-lock.json

* use splitWords from jac-kit

* upgrade jac-kit to 4.1.53

* upgrade jac-kit to 4.1.53
  • Loading branch information
HalcyonJAC authored Jan 3, 2025
1 parent 7cd6a4c commit 43d7f2b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
57 changes: 53 additions & 4 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
Expand Up @@ -29,7 +29,7 @@
"lint-ci": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --no-fix --ignore-path .gitignore"
},
"dependencies": {
"@jac-uk/jac-kit": "4.1.41",
"@jac-uk/jac-kit": "4.1.53",
"@ministryofjustice/frontend": "0.2.4",
"@sentry/vue": "^8.33.1",
"@vue/compat": "^3.3.4",
Expand Down
13 changes: 2 additions & 11 deletions src/components/Form/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<script>
import { isValidNumberForRegion } from 'libphonenumber-js';
import { formatDate } from '@/helpers/date';
import { splitWords } from '@jac-uk/jac-kit/helpers/splitWords';
export default {
name: 'FormField',
Expand Down Expand Up @@ -79,17 +80,7 @@ export default {
words() {
const value = this.modelValue;
const result = value ? value : '';
return [].concat(...result
.split(/[^a-z'-]/i) //split into array at every occurance of a character which is NOT: a-z or ' or -
.filter(item => item != '') // remove any empty items from array
.filter(item => item != '\'') // remove any items which are just a apostrophe
.filter(item => item != '-') // remove any items which are just a hyphen
.map((item, i) => { // with the above array
if (i, item.replace(/[^-]/g, '').length >= 4) { // find any items containing more than or equal to 4 hyphens (4 allows for a trailing hyphen which is not counted in next set)
item = item.match(/((?:[^-]*?-){3}[^-]*?)-|([\S\s]+)/g); // if an 'offending' item occurs, group every 4 words, ignoring the hyphen between groups [ie. 'one-one-one-one-two-two-two-two' (eight words, seven hyphens) 'one-one-one-one-' 'two-two-two-two']
}
return item; // add array in position of word
})); // flatten array
return splitWords(result);
},
},
mounted: function () {
Expand Down

0 comments on commit 43d7f2b

Please sign in to comment.