Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Tighten up function detection to look for polyfills. Relax Barcode ap…
Browse files Browse the repository at this point in the history
…i check
  • Loading branch information
Thomas101 committed Mar 9, 2021
1 parent a6094cd commit a1212dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/chromium-detector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* @param v: value to check
* @return true if the value is of type function
*/
const isFunction = (v) => typeof (v) === 'function'
const isFunction = (v) => {
return (
typeof (v) === 'function' &&
typeof (v.toString) === 'function' &&
v.toString().includes('[native code]')
)
}

/**
* @param v: value to check
Expand Down Expand Up @@ -216,6 +222,7 @@ const descriptors = {
{
url: 'https://chromestatus.com/feature/4757990523535360',
name: 'Barcode Detection API',
optional: true, // Some electron instances don't implement this
test: () => isFunction(window.BarcodeDetector)
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chromium-detector",
"version": "1.0.0",
"version": "1.0.1",
"description": "Feature detects the running version of Chromium without any UserAgent parsing",
"main": "dist/chromium-detector.js",
"module": "index.js",
Expand Down

0 comments on commit a1212dc

Please sign in to comment.