Skip to content

Commit f03a999

Browse files
feat(CSAF2.1): #373 add mandatory test 6.1.44 - add comment to containMultipleUnescapedStars
1 parent 9943609 commit f03a999

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,19 @@ const validate = ajv.compile(inputSchema)
7878
*/
7979

8080
/**
81+
* Checks if the `stringToCheck` includes more than one unescaped `*` character. A `*` character
82+
* can be escaped by prefixing it with a backslash (`\`).
8183
*
8284
* @param {string} stringToCheck
8385
* @return {boolean}
8486
*/
8587
export function containMultipleUnescapedStars(stringToCheck) {
8688
const regex = /\*/g
87-
return (stringToCheck.replace(/\\\*/g, '').match(regex)?.length ?? 0) > 1
89+
return (
90+
(stringToCheck
91+
.replace(/\\\*/g, '') // remove escaped '*'
92+
.match(regex)?.length ?? 0) > 1 // check if there is more than 1 unescaped '*'
93+
)
8894
}
8995

9096
/**

0 commit comments

Comments
 (0)