Improve JS detection

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

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

Loading…
Cancel
Save