Improve JS detection

main
Elbert Alias 2 years ago
parent 4d6e1a04e8
commit 9bc44d8b63

@ -65,16 +65,25 @@ function getJs(page, technologies = Wappalyzer.technologies) {
chains.forEach((chain) => {
chain = chain.replace(/\[([^\]]+)\]/g, '.$1')
const value = chain
.split('.')
.reduce(
const parts = chain.split('.')
const root = /^[a-z_$][a-z0-9_$]*$/i.test(parts[0])
? // eslint-disable-next-line no-new-func
new Function(
`return typeof ${
parts[0]
} === 'undefined' ? undefined : ${parts.shift()}`
)()
: window
const value = parts.reduce(
(value, method) =>
value &&
value instanceof Object &&
Object.prototype.hasOwnProperty.call(value, method)
? value[method]
: '__UNDEFINED__',
window
root || '__UNDEFINED__'
)
if (value !== '__UNDEFINED__') {

Loading…
Cancel
Save