We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e18f04 commit 405410fCopy full SHA for 405410f
1 file changed
packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs
@@ -32,6 +32,13 @@ export class CharacterCount extends ConfigurableComponent {
32
*/
33
segmenter = null
34
35
+ /**
36
+ * Split words between consecutive whitespace
37
+ *
38
+ * @type {RegExp}
39
+ */
40
+ separator = /\s+/g
41
+
42
/** @private */
43
$visibleCountMessage
44
@@ -490,7 +497,7 @@ export class CharacterCount extends ConfigurableComponent {
490
497
491
498
words(text) {
492
499
if (this.config.maxwords !== undefined) {
493
- return text.split(/\s+/g).filter(Boolean).length
500
+ return text.split(this.separator).filter(Boolean).length
494
501
}
495
502
496
503
const segments = this.segmenter
0 commit comments