bowser-js / bowser

a browser detector
Other
5.49k stars 487 forks source link

Version constraints with a space after comparison operator erroneously return true #303

Open outoftime opened 5 years ago

outoftime commented 5 years ago

window.navigator.userAgent of the browser is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.92 Safari/537.4

Calling parser.satisfies({chrome: '>= 23'}) returns true, even though this is Chrome 22.

Removing the space after the >= fixes the problem.

Ideally, the parser should handle spaces after the comparison correctly. If this is not practical, then invoking satisfies with a version string like that should throw an error.

lancedikson commented 5 years ago

Thanks, @outoftime. Quite a tricky issue, needs to be fixed.