mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge branch 'release/2.2.0' into production
This commit is contained in:
commit
1d66cb9e89
@ -1,5 +1,9 @@
|
||||
# Bowser Changelog
|
||||
|
||||
### 2.2.0 (April 7, 2019)
|
||||
- [ADD] Add short aliases for browser names (#295)
|
||||
- [FIX] Fix Yandex Browser version detection (#308)
|
||||
|
||||
### 2.1.2 (March 6, 2019)
|
||||
- [FIX] Fix buggy `getFirstMatch` reference
|
||||
|
||||
|
@ -12,12 +12,23 @@ If it's a small hot-fix, an improvement to the docs, or added support for a new
|
||||
|
||||
Following these simple rules will really help maintain the repo! Thanks ❤️
|
||||
|
||||
## Adding Tests
|
||||
## Adding Browser Support and Tests
|
||||
|
||||
See the list in `test/acceptance/useragentstrings.yml` with example user agents and their expected `bowser` object.
|
||||
|
||||
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
|
||||
check if all tests are still passing.
|
||||
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and check if all tests are still passing. Also, make sure to keep the list of browser aliases up-to-date in `src/constants.js`.
|
||||
|
||||
For creating aliases, keep the following guidelines in mind:
|
||||
- use only lowercase letters for names
|
||||
- replace special characters such as space and dashes by underscore
|
||||
- whenever possible drop the word `browser` from the original browser name
|
||||
- always check for possible duplicates
|
||||
- aliases are supposed to also be a shorter version of the original name
|
||||
|
||||
Examples:
|
||||
`Opera Coast` --> `opera_coast`
|
||||
`UC Browser` --> `uc`
|
||||
`SeaMonkey` --> `seamonkey`
|
||||
|
||||
## Testing
|
||||
|
||||
|
10
README.md
10
README.md
@ -131,8 +131,14 @@ Thus, you can define OS or platform specific rules and they will have more prior
|
||||
|
||||
More of API and possibilities you will find in the `docs` folder.
|
||||
|
||||
### Similar Projects
|
||||
### Browser names for `.satisfies()`
|
||||
|
||||
By default you are supposed to use the full browser name for `.satisfies`.
|
||||
But, there's a short way to define a browser using short aliases. The full
|
||||
list of aliases can be found in [the file](src/constants.js).
|
||||
|
||||
## Similar Projects
|
||||
* [Kong](https://github.com/BigBadBleuCheese/Kong) - A C# port of Bowser.
|
||||
|
||||
### License
|
||||
## License
|
||||
Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -572,7 +572,7 @@ const result = parser.getResult();</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -1670,7 +1670,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line463">line 463</a>
|
||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line470">line 470</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -2488,7 +2488,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line472">line 472</a>
|
||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line479">line 479</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -2793,7 +2793,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -105,7 +105,7 @@ export default Bowser;
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
172
docs/global.html
172
docs/global.html
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -133,7 +133,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line78">line 78</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line80">line 80</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -296,6 +296,162 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getBrowserAlias"><span class="type-signature"></span>getBrowserAlias<span class="signature">(browserName)</span><span class="type-signature"> → {string}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line202">line 202</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Get short version/alias for a browser name</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>getBrowserAlias('Microsoft Edge') // edge</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>browserName</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getFirstMatch"><span class="type-signature"></span>getFirstMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> → {Array|Object|*|boolean|string}</span></h4>
|
||||
|
||||
|
||||
@ -308,7 +464,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line8">line 8</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line10">line 10</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -494,7 +650,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line19">line 19</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line21">line 21</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -675,7 +831,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line107">line 107</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line109">line 109</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -831,7 +987,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line179">line 179</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line181">line 181</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -1005,7 +1161,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line31">line 31</a>
|
||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line33">line 33</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@ -1839,7 +1995,7 @@ like <code>"iPhone"</code> or <code>"Kindle Fire HD 7"</code
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -136,10 +136,13 @@ const isValidBrowser = browser.satisfies({
|
||||
});</code></pre><p>Settings for any particular OS or platform has more priority and redefines settings of standalone browsers.
|
||||
Thus, you can define OS or platform specific rules and they will have more priority in the end.</p>
|
||||
<p>More of API and possibilities you will find in the <code>docs</code> folder.</p>
|
||||
<h3>Similar Projects</h3><ul>
|
||||
<h3>Browser names for <code>.satisfies()</code></h3><p>By default you are supposed to use the full browser name for <code>.satisfies</code>.
|
||||
But, there's a short way to define a browser using short aliases. The full
|
||||
list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
|
||||
<h2>Similar Projects</h2><ul>
|
||||
<li><a href="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li>
|
||||
</ul>
|
||||
<h3>License</h3><p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article>
|
||||
<h2>License</h2><p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article>
|
||||
</section>
|
||||
|
||||
|
||||
@ -154,7 +157,7 @@ Thus, you can define OS or platform specific rules and they will have more prior
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -435,7 +435,7 @@ class Parser {
|
||||
|
||||
if (browsersCounter > 0) {
|
||||
const browserNames = Object.keys(browsers);
|
||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name)));
|
||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name, true)));
|
||||
|
||||
if (matchingDefinition !== void 0) {
|
||||
return this.compareVersion(browsers[matchingDefinition]);
|
||||
@ -445,8 +445,15 @@ class Parser {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
isBrowser(browserName) {
|
||||
return this.getBrowserName(true) === String(browserName).toLowerCase();
|
||||
isBrowser(browserName, loosely = false) {
|
||||
const defaultBrowserName = this.getBrowserName();
|
||||
const possibleNames = [defaultBrowserName.toLowerCase()];
|
||||
|
||||
if (loosely) {
|
||||
possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase());
|
||||
}
|
||||
|
||||
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
||||
}
|
||||
|
||||
compareVersion(version) {
|
||||
@ -532,7 +539,7 @@ export default Parser;
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@ -41,7 +41,9 @@
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>export default class Utils {
|
||||
<pre class="prettyprint source linenums"><code>import { BROWSER_ALIASES_MAP } from './constants.js';
|
||||
|
||||
export default class Utils {
|
||||
/**
|
||||
* Get first matched item for a string
|
||||
* @param {RegExp} regexp
|
||||
@ -230,6 +232,19 @@
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get short version/alias for a browser name
|
||||
*
|
||||
* @example
|
||||
* getBrowserAlias('Microsoft Edge') // edge
|
||||
*
|
||||
* @param {string} browserName
|
||||
* @return {string}
|
||||
*/
|
||||
static getBrowserAlias(browserName) {
|
||||
return BROWSER_ALIASES_MAP[browserName];
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
@ -245,7 +260,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Mar 06 2019 14:31:23 GMT+0200 (EET) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bowser",
|
||||
"version": "2.1.2",
|
||||
"version": "2.2.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bowser",
|
||||
"version": "2.1.2",
|
||||
"version": "2.2.0",
|
||||
"description": "Lightweight browser detector",
|
||||
"keywords": [
|
||||
"browser",
|
||||
|
41
src/constants.js
Normal file
41
src/constants.js
Normal file
@ -0,0 +1,41 @@
|
||||
// NOTE: this list must be up-to-date with browsers listed in
|
||||
// test/acceptance/useragentstrings.yml
|
||||
const BROWSER_ALIASES_MAP = {
|
||||
'Amazon Silk': 'amazon_silk',
|
||||
'Android Browser': 'android',
|
||||
Bada: 'bada',
|
||||
BlackBerry: 'blackberry',
|
||||
Chrome: 'chrome',
|
||||
Chromium: 'chromium',
|
||||
Epiphany: 'epiphany',
|
||||
Firefox: 'firefox',
|
||||
Focus: 'focus',
|
||||
Generic: 'generic',
|
||||
Googlebot: 'googlebot',
|
||||
'Internet Explorer': 'ie',
|
||||
'K-Meleon': 'k_meleon',
|
||||
Maxthon: 'maxthon',
|
||||
'Microsoft Edge': 'edge',
|
||||
'MZ Browser': 'mz',
|
||||
'NAVER Whale Browser': 'naver',
|
||||
Opera: 'opera',
|
||||
'Opera Coast': 'opera_coast',
|
||||
PhantomJS: 'phantomjs',
|
||||
Puffin: 'puffin',
|
||||
QupZilla: 'qupzilla',
|
||||
Safari: 'safari',
|
||||
Sailfish: 'sailfish',
|
||||
SeaMonkey: 'seamonkey',
|
||||
Sleipnir: 'sleipnir',
|
||||
Swing: 'swing',
|
||||
Tizen: 'tizen',
|
||||
'UC Browser': 'uc',
|
||||
Vivaldi: 'vivaldi',
|
||||
'WebOS Browser': 'webos',
|
||||
WeChat: 'wechat',
|
||||
'Yandex Browser': 'yandex',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
BROWSER_ALIASES_MAP,
|
||||
};
|
@ -174,7 +174,7 @@ const browsersList = [
|
||||
const browser = {
|
||||
name: 'Yandex Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
const version = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
|
@ -392,7 +392,7 @@ class Parser {
|
||||
|
||||
if (browsersCounter > 0) {
|
||||
const browserNames = Object.keys(browsers);
|
||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name)));
|
||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name, true)));
|
||||
|
||||
if (matchingDefinition !== void 0) {
|
||||
return this.compareVersion(browsers[matchingDefinition]);
|
||||
@ -402,8 +402,15 @@ class Parser {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
isBrowser(browserName) {
|
||||
return this.getBrowserName(true) === String(browserName).toLowerCase();
|
||||
isBrowser(browserName, loosely = false) {
|
||||
const defaultBrowserName = this.getBrowserName();
|
||||
const possibleNames = [defaultBrowserName.toLowerCase()];
|
||||
|
||||
if (loosely) {
|
||||
possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase());
|
||||
}
|
||||
|
||||
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
||||
}
|
||||
|
||||
compareVersion(version) {
|
||||
|
15
src/utils.js
15
src/utils.js
@ -1,3 +1,5 @@
|
||||
import { BROWSER_ALIASES_MAP } from './constants.js';
|
||||
|
||||
export default class Utils {
|
||||
/**
|
||||
* Get first matched item for a string
|
||||
@ -187,4 +189,17 @@ export default class Utils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get short version/alias for a browser name
|
||||
*
|
||||
* @example
|
||||
* getBrowserAlias('Microsoft Edge') // edge
|
||||
*
|
||||
* @param {string} browserName
|
||||
* @return {string}
|
||||
*/
|
||||
static getBrowserAlias(browserName) {
|
||||
return BROWSER_ALIASES_MAP[browserName];
|
||||
}
|
||||
}
|
||||
|
@ -673,6 +673,22 @@
|
||||
vendor: "Nexus"
|
||||
engine:
|
||||
name: "Blink"
|
||||
-
|
||||
ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 YaBrowser/19.3.3.157.10 Mobile/15E148 Safari/605.1"
|
||||
spec:
|
||||
browser:
|
||||
name: "Yandex Browser"
|
||||
version: "19.3.3.157.10"
|
||||
os:
|
||||
name: "iOS"
|
||||
version: "12.2"
|
||||
platform:
|
||||
type: "mobile"
|
||||
vendor: "Apple"
|
||||
model: "iPhone"
|
||||
engine:
|
||||
name: "WebKit"
|
||||
version: "605.1.15"
|
||||
Safari:
|
||||
-
|
||||
ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2"
|
||||
|
15
test/unit/constants.js
Normal file
15
test/unit/constants.js
Normal file
@ -0,0 +1,15 @@
|
||||
import test from 'ava';
|
||||
import { BROWSER_ALIASES_MAP } from '../../src/constants';
|
||||
|
||||
test('check duplicate aliases', (t) => {
|
||||
const aliasesList = Object.keys(BROWSER_ALIASES_MAP).map(value => (BROWSER_ALIASES_MAP[value]));
|
||||
let foundOnce, foundTwice;
|
||||
|
||||
const duplicates = aliasesList.filter(item => {
|
||||
foundOnce = aliasesList.indexOf(item);
|
||||
foundTwice = aliasesList.indexOf(item, foundOnce + 1);
|
||||
return +foundTwice !== -1;
|
||||
});
|
||||
|
||||
t.deepEqual(duplicates, []);
|
||||
});
|
@ -5,6 +5,9 @@ import Parser from '../../src/parser';
|
||||
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165';
|
||||
const parser = new Parser(UA, true);
|
||||
|
||||
const EDGE_UA = 'Mozilla/5.0 (Linux; Android 8.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.0 Mobile Safari/537.36 EdgA/41.1.35.1';
|
||||
const edgeParser = new Parser(EDGE_UA, true);
|
||||
|
||||
test('constructor', (t) => {
|
||||
t.truthy(parser instanceof Parser);
|
||||
});
|
||||
@ -145,6 +148,13 @@ test('Parser.satisfies for versionless UA strings', (t) => {
|
||||
}), void 0);
|
||||
});
|
||||
|
||||
test('Parser.satisfies should consider aliases while handling browsers', (t) => {
|
||||
t.is(edgeParser.satisfies({ 'Microsoft Edge': '=41.1.35.1' }), true);
|
||||
t.is(edgeParser.satisfies({ 'microsoft edge': '=41.1.35.1' }), true);
|
||||
t.is(edgeParser.satisfies({ 'edge': '=41.1.35.1' }), true);
|
||||
t.is(edgeParser.satisfies({ 'Edge': '=41.1.35.1' }), true);
|
||||
});
|
||||
|
||||
test('Parser.is should pass', (t) => {
|
||||
t.is(parser.is('opera'), true);
|
||||
t.is(parser.is('desktop'), true);
|
||||
@ -158,3 +168,19 @@ test('Parser.some should pass', (t) => {
|
||||
t.is(parser.some([]), false);
|
||||
t.is(parser.some(), false);
|
||||
});
|
||||
|
||||
test('Parser.isBrowser should pass when not loosely checking', (t) => {
|
||||
t.is(edgeParser.isBrowser('Microsoft Edge', false), true);
|
||||
t.is(edgeParser.isBrowser('microsoft edge', false), true);
|
||||
t.is(edgeParser.isBrowser('mIcrosoft eDge', false), true);
|
||||
t.is(edgeParser.isBrowser('edge', false), false);
|
||||
t.is(edgeParser.isBrowser('Edge', false), false);
|
||||
});
|
||||
|
||||
test('Parser.isBrowser should pass when loosely checking', (t) => {
|
||||
t.is(edgeParser.isBrowser('Microsoft Edge', true), true);
|
||||
t.is(edgeParser.isBrowser('microsoft edge', true), true);
|
||||
t.is(edgeParser.isBrowser('mIcrosoft eDge', true), true);
|
||||
t.is(edgeParser.isBrowser('edge', true), true);
|
||||
t.is(edgeParser.isBrowser('Edge', true), true);
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import test from 'ava';
|
||||
import {
|
||||
getBrowserAlias,
|
||||
getFirstMatch,
|
||||
getWindowsVersionName,
|
||||
compareVersions,
|
||||
@ -50,3 +51,8 @@ test('compareVersions', (t) => {
|
||||
t.is(compareVersions(versionA, versionB, isLoose), result, `version ${versionA} should be ${matching} version ${versionB}`);
|
||||
});
|
||||
});
|
||||
|
||||
test('getBrowserAlias', (t) => {
|
||||
t.is(getBrowserAlias('Microsoft Edge'), 'edge');
|
||||
t.is(getBrowserAlias('Unexisting Browser'), void 0);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user