@@ -13,22 +13,22 @@ const detectors = {
13
13
}
14
14
15
15
exports . hasVue = function ( context ) {
16
- return isMatching ( detectors . vue , context )
16
+ return match ( detectors . vue , context )
17
17
}
18
18
19
19
exports . getVueMeta = async function ( context ) {
20
20
const meta = { }
21
21
await Promise . all (
22
22
Object . keys ( detectors . meta ) . map ( async ( key ) => {
23
- meta [ key ] = await isMatching ( detectors . meta [ key ] , context )
23
+ meta [ key ] = await match ( detectors . meta [ key ] , context )
24
24
} )
25
25
)
26
26
return meta
27
27
}
28
28
29
29
exports . getFramework = async function ( context ) {
30
30
for ( const framework of Object . keys ( detectors . frameworks ) ) {
31
- if ( await isMatching ( detectors . frameworks [ framework ] . detectors , context ) ) {
31
+ if ( await match ( detectors . frameworks [ framework ] . detectors , context ) ) {
32
32
return detectors . frameworks [ framework ] . metas
33
33
}
34
34
}
@@ -37,7 +37,7 @@ exports.getFramework = async function (context) {
37
37
38
38
exports . getUI = async function ( context ) {
39
39
for ( const ui of Object . keys ( detectors . uis ) ) {
40
- if ( await isMatching ( detectors . uis [ ui ] . detectors , context ) ) {
40
+ if ( await match ( detectors . uis [ ui ] . detectors , context ) ) {
41
41
return detectors . uis [ ui ] . metas
42
42
}
43
43
}
@@ -49,7 +49,7 @@ exports.getPlugins = async function (context) {
49
49
50
50
await Promise . all (
51
51
Object . keys ( detectors . plugins ) . map ( async ( plugin ) => {
52
- if ( await isMatching ( detectors . plugins [ plugin ] . detectors , context ) ) {
52
+ if ( await match ( detectors . plugins [ plugin ] . detectors , context ) ) {
53
53
plugins . add ( detectors . plugins [ plugin ] . metas )
54
54
}
55
55
} )
@@ -63,7 +63,7 @@ exports.getNuxtMeta = async function (context) {
63
63
64
64
await Promise . all (
65
65
Object . keys ( detectors . nuxt . meta ) . map ( async ( key ) => {
66
- meta [ key ] = await isMatching ( detectors . nuxt . meta [ key ] , context )
66
+ meta [ key ] = await match ( detectors . nuxt . meta [ key ] , context )
67
67
} )
68
68
)
69
69
@@ -75,7 +75,7 @@ exports.getNuxtModules = async function (context) {
75
75
76
76
await Promise . all (
77
77
Object . keys ( detectors . nuxt . modules ) . map ( async ( name ) => {
78
- if ( await isMatching ( detectors . nuxt . modules [ name ] . detectors , context ) ) {
78
+ if ( await match ( detectors . nuxt . modules [ name ] . detectors , context ) ) {
79
79
modules . add ( detectors . nuxt . modules [ name ] . metas )
80
80
}
81
81
} )
@@ -84,7 +84,15 @@ exports.getNuxtModules = async function (context) {
84
84
return Array . from ( modules )
85
85
}
86
86
87
- async function isMatching ( detector , { originalHtml, html, scripts, page } ) {
87
+ async function match ( detector , { originalHtml, html, scripts, page } ) {
88
+ // JS eval (for string value)
89
+ if ( detector . eval ) {
90
+ for ( const js of asArray ( detector . eval ) ) {
91
+ const value = await page . evaluate ( js )
92
+ if ( value ) return value
93
+ }
94
+ return null
95
+ }
88
96
// If we can detect technology from response html
89
97
if ( detector . originalHtml ) {
90
98
for ( const pattern of parsePatterns ( detector . originalHtml ) ) {
0 commit comments