Skip to content

Commit

Permalink
Rich Text: Update the regex that checks the format of className in Fo…
Browse files Browse the repository at this point in the history
…rmat Types to allow underscores (#56599)
  • Loading branch information
alexandrebuffet authored Nov 28, 2023
1 parent 726b008 commit c6be294
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/rich-text/src/register-format-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export function registerFormatType( name, settings ) {
return;
}

if ( ! /^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test( settings.className ) ) {
if ( ! /^[_a-zA-Z]+[a-zA-Z0-9_-]*$/.test( settings.className ) ) {
window.console.error(
'A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'
'A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers.'
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rich-text/src/test/register-format-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe( 'registerFormatType', () => {
className: 'invalid class name',
} );
expect( console ).toHaveErroredWith(
'A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'
'A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers.'
);
expect( format ).toBeUndefined();
} );
Expand Down

0 comments on commit c6be294

Please sign in to comment.