chore(repo): fix the regex to validate commits (#31630)

## Current Behavior

The string regex the script uses to validate commits is not correctly
escaped.

## Expected Behavior

The string regex the script uses to validate commits should be correctly
escaped.
This commit is contained in:
Leosvel Pérez Espinosa 2025-06-18 19:36:14 +02:00 committed by GitHub
parent db6e0d1217
commit 1a9405b0bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,7 +43,7 @@ if (!gitMessage) {
const allowedTypes = types.map((type) => type.value).join('|'); const allowedTypes = types.map((type) => type.value).join('|');
const allowedScopes = scopes.map((scope) => scope.value).join('|'); const allowedScopes = scopes.map((scope) => scope.value).join('|');
const commitMsgRegex = `(${allowedTypes})\\((${allowedScopes})\\)!?:\\s(([a-z0-9:\-\s])+)`; const commitMsgRegex = `(${allowedTypes})\\((${allowedScopes})\\)!?:\\s(([a-z0-9:\\-\\s])+)`;
const matchCommit = new RegExp(commitMsgRegex, 'g').test(gitMessage); const matchCommit = new RegExp(commitMsgRegex, 'g').test(gitMessage);
const matchRevert = /Revert/gi.test(gitMessage); const matchRevert = /Revert/gi.test(gitMessage);