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

Other: Make Edge browser checking a bit more strict.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
7a0055921d
2 измененных файлов с 5 добавлено и 3 удалено
  1. 1 1
      packages/ckeditor5-utils/src/env.js
  2. 4 2
      packages/ckeditor5-utils/tests/env.js

+ 1 - 1
packages/ckeditor5-utils/src/env.js

@@ -53,5 +53,5 @@ export function isMac( userAgent ) {
  * @returns {Boolean} Whether User Agent is Edge or not.
  */
 export function isEdge( userAgent ) {
-	return userAgent.indexOf( 'edge' ) > -1;
+	return !!userAgent.match( /edge\/(\d+.?\d*)/ );
 }

+ 4 - 2
packages/ckeditor5-utils/tests/env.js

@@ -40,14 +40,16 @@ describe( 'Env', () => {
 
 	describe( 'isEdge()', () => {
 		it( 'returns true for Edge UA strings', () => {
-			expect( isEdge( 'edge' ) ).to.be.true;
-			expect( isEdge( 'foo edge bar' ) ).to.be.true;
+			expect( isEdge( 'edge/12' ) ).to.be.true;
+			expect( isEdge( 'foo edge/12 bar' ) ).to.be.true;
 		} );
 
 		it( 'returns false for non–Edge UA strings', () => {
 			expect( isEdge( '' ) ).to.be.false;
 			expect( isEdge( 'mac' ) ).to.be.false;
 			expect( isEdge( 'foo' ) ).to.be.false;
+			expect( isEdge( 'ledge' ) ).to.be.false;
+			expect( isEdge( 'foo edge bar' ) ).to.be.false;
 		} );
 	} );
 } );