Sfoglia il codice sorgente

Fix regexp pattern for mention.

Maciej Gołaszewski 6 anni fa
parent
commit
76b09eb90e

+ 2 - 2
packages/ckeditor5-mention/src/mentionui.js

@@ -552,8 +552,8 @@ export function createRegExp( marker, minimumCharacters ) {
 	// - 1: Marker character.
 	// - 2: Mention input (with support of minimal lenght to trigger UI)
 	// The pattern matches up to the caret (end of string switch - $).
-	//               (0:      opening sequence       )(1:  marker   )(2:                typed mention                  )$
-	const pattern = `(?:^|[ ${ openAfterCharacters }])([${ marker }])([_${ mentionCharacters }]${ numberOfCharacters }?)$`;
+	//               (0:      opening sequence       )(1:  marker   )(2:                typed mention                 )$
+	const pattern = `(?:^|[ ${ openAfterCharacters }])([${ marker }])([_${ mentionCharacters }]${ numberOfCharacters })$`;
 
 	return new RegExp( pattern, 'u' );
 }

+ 2 - 2
packages/ckeditor5-mention/tests/mentionui.js

@@ -468,14 +468,14 @@ describe( 'MentionUI', () => {
 				featureDetection.isUnicodeGroupSupported = false;
 				createRegExp( '@', 2 );
 				sinon.assert.calledOnce( regExpStub );
-				sinon.assert.calledWithExactly( regExpStub, '(?:^|[ \\(\\[{"\'])([@])([_a-zA-ZÀ-ž0-9]{2,}?)$', 'u' );
+				sinon.assert.calledWithExactly( regExpStub, '(?:^|[ \\(\\[{"\'])([@])([_a-zA-ZÀ-ž0-9]{2,})$', 'u' );
 			} );
 
 			it( 'returns a ES2018 RegExp for browsers supporting Unicode punctuation groups', () => {
 				featureDetection.isUnicodeGroupSupported = true;
 				createRegExp( '@', 2 );
 				sinon.assert.calledOnce( regExpStub );
-				sinon.assert.calledWithExactly( regExpStub, '(?:^|[ \\p{Ps}\\p{Pi}"\'])([@])([_\\p{L}\\p{N}]{2,}?)$', 'u' );
+				sinon.assert.calledWithExactly( regExpStub, '(?:^|[ \\p{Ps}\\p{Pi}"\'])([@])([_\\p{L}\\p{N}]{2,})$', 'u' );
 			} );
 		} );