8
0
Просмотр исходного кода

Merge pull request #227 from ckeditor/t/192

Docs: Update `utils/uid` documentation. Closes #192.
Piotrek Koszuliński 8 лет назад
Родитель
Сommit
8144652ed9
2 измененных файлов с 8 добавлено и 6 удалено
  1. 3 3
      packages/ckeditor5-utils/src/uid.js
  2. 5 3
      packages/ckeditor5-utils/tests/uid.js

+ 3 - 3
packages/ckeditor5-utils/src/uid.js

@@ -8,10 +8,10 @@
  */
 
 /**
- * Returns a unique id. This id is a number (starting from 1) which will never get repeated on successive calls
- * to this method.
+ * Returns a unique id. This id consist of an 'e' character and a randomly generated string of 32 aphanumeric characters.
+ * Each character in uid string represents a hexadecimal digit (base 16).
  *
- * @returns {String} A number representing the id.
+ * @returns {String} A hexadecimal number representing the id.
  */
 export default function uid() {
 	let uuid = 'e'; // Make sure that id does not start with number.

+ 5 - 3
packages/ckeditor5-utils/tests/uid.js

@@ -16,9 +16,11 @@ describe( 'utils', () => {
 			expect( id2 ).to.be.a( 'string' ).to.not.equal( id1 ).to.not.equal( id3 );
 			expect( id3 ).to.be.a( 'string' ).to.not.equal( id1 ).to.not.equal( id2 );
 
-			expect( id1 ).to.match( /^[a-z][a-z0-9]{32}$/ );
-			expect( id2 ).to.match( /^[a-z][a-z0-9]{32}$/ );
-			expect( id3 ).to.match( /^[a-z][a-z0-9]{32}$/ );
+			const uuidRegex = /^e[a-f0-9]{32}$/;
+
+			expect( id1 ).to.match( uuidRegex );
+			expect( id2 ).to.match( uuidRegex );
+			expect( id3 ).to.match( uuidRegex );
 		} );
 	} );
 } );