Skip to content

Commit 2a2398a

Browse files
committed
fix: revert detection of version in detectors
1 parent 3824b76 commit 2a2398a

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

detectors/vue.meta.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"version": {
3-
"eval": "(window.$nuxt && window.$nuxt.$root && window.$nuxt.$root.constructor.version) || (window.Vue && window.Vue.version) || [...document.querySelectorAll('*')].map((el) => el.__vue__ && el.__vue__.$root && el.__vue__.$root.constructor.version).filter(Boolean)[0]"
4-
},
52
"ssr": {
63
"originalHtml": "<div [^>]*data-server-rendered=\"true\"",
74
"html": [

src/detectors.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ const detectors = {
1313
}
1414

1515
exports.hasVue = function (context) {
16-
return match(detectors.vue, context)
16+
return isMatching(detectors.vue, context)
1717
}
1818

1919
exports.getVueMeta = async function(context) {
2020
const meta = {}
2121
await Promise.all(
2222
Object.keys(detectors.meta).map(async (key) => {
23-
meta[key] = await match(detectors.meta[key], context)
23+
meta[key] = await isMatching(detectors.meta[key], context)
2424
})
2525
)
2626
return meta
2727
}
2828

2929
exports.getFramework = async function (context) {
3030
for (const framework of Object.keys(detectors.frameworks)) {
31-
if (await match(detectors.frameworks[framework].detectors, context)) {
31+
if (await isMatching(detectors.frameworks[framework].detectors, context)) {
3232
return detectors.frameworks[framework].metas
3333
}
3434
}
@@ -37,7 +37,7 @@ exports.getFramework = async function (context) {
3737

3838
exports.getUI = async function (context) {
3939
for (const ui of Object.keys(detectors.uis)) {
40-
if (await match(detectors.uis[ui].detectors, context)) {
40+
if (await isMatching(detectors.uis[ui].detectors, context)) {
4141
return detectors.uis[ui].metas
4242
}
4343
}
@@ -49,7 +49,7 @@ exports.getPlugins = async function (context) {
4949

5050
await Promise.all(
5151
Object.keys(detectors.plugins).map(async (plugin) => {
52-
if (await match(detectors.plugins[plugin].detectors, context)) {
52+
if (await isMatching(detectors.plugins[plugin].detectors, context)) {
5353
plugins.add(detectors.plugins[plugin].metas)
5454
}
5555
})
@@ -63,7 +63,7 @@ exports.getNuxtMeta = async function (context) {
6363

6464
await Promise.all(
6565
Object.keys(detectors.nuxt.meta).map(async (key) => {
66-
meta[key] = await match(detectors.nuxt.meta[key], context)
66+
meta[key] = await isMatching(detectors.nuxt.meta[key], context)
6767
})
6868
)
6969

@@ -75,7 +75,7 @@ exports.getNuxtModules = async function (context) {
7575

7676
await Promise.all(
7777
Object.keys(detectors.nuxt.modules).map(async (name) => {
78-
if (await match(detectors.nuxt.modules[name].detectors, context)) {
78+
if (await isMatching(detectors.nuxt.modules[name].detectors, context)) {
7979
modules.add(detectors.nuxt.modules[name].metas)
8080
}
8181
})
@@ -84,15 +84,7 @@ exports.getNuxtModules = async function (context) {
8484
return Array.from(modules)
8585
}
8686

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(`String(${js})`)
92-
if (value) return value
93-
}
94-
return null
95-
}
87+
async function isMatching (detector, { originalHtml, html, scripts, page }) {
9688
// If we can detect technology from response html
9789
if (detector.originalHtml) {
9890
for (const pattern of parsePatterns(detector.originalHtml)) {

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ module.exports = async function (originalUrl) {
135135
infos.meta.language = matches[1].split('-')[0]
136136
}
137137

138+
// Get Vue version
139+
const version = await page.evaluate('(window.$nuxt && window.$nuxt.$root && window.$nuxt.$root.constructor.version) || (window.Vue && window.Vue.version) || [...document.querySelectorAll("*")].map((el) => el.__vue__ && el.__vue__.$root && el.__vue__.$root.constructor.version).filter(Boolean)[0]')
140+
if (version) {
141+
infos.vueVersion = version
142+
}
143+
138144
// Get Vue metas
139-
const { ssr, version } = await getVueMeta(context)
140-
infos.vueVersion = version
145+
const { ssr } = await getVueMeta(context)
141146
infos.hasSSR = ssr
142147

143148
// Get Vue ecosystem infos

0 commit comments

Comments
 (0)