-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
src/env.js
Outdated
* @returns {Boolean} Whether User Agent is Edge or not. | ||
*/ | ||
export function isEdge( userAgent ) { | ||
return userAgent.indexOf( 'edge' ) > -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unsafe. There are many words with "edge" in them. Something more precise would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, feel free to look into CKE4's code:
https://github.com/ckeditor/ckeditor-dev/blob/master/core/env.js#L20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Reinmar I'm not 100% sure but it looks like [ /]
in that regex could be restricted to:
/edge\/(\d+.?\d*)/
I couldn't find why there is space allowed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describes only Edge/<EdgeHTML Rev>.<Windows Build>
as possible value so I've set the regex accordingly to this.
@@ -31,4 +37,19 @@ describe( 'Env', () => { | |||
expect( isMac( 'foo' ) ).to.be.false; | |||
} ); | |||
} ); | |||
|
|||
describe( 'isEdge()', () => { | |||
it( 'returns true for Edge UA strings', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a single real UA string ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I've copied from other test. I'm adding some real ones right now ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK... I was too slow 😞
Suggested merge commit message (convention)
Feature: Introduce
env.isEdge
property.Additional information