fix: 公司官网检测链接跳转和有效性

内容
This commit is contained in:
奇趣保罗 2024-06-24 01:26:34 +08:00
parent 4ff5188040
commit 8a7fa8b9da
1 changed files with 86 additions and 35 deletions

View File

@ -2,10 +2,16 @@
const https = require('https'); const https = require('https');
const locale = 'zh-TW';
const homeUrl = 'https://felo.me'; const homeUrl = 'https://felo.me';
const meetUrl = 'https://meet.felo.me'; const meetUrl = 'https://meet.felo.me';
const imUrl = 'https://im.felo.me'; const imUrl = 'https://im.felo.me';
// const homeUrl = 'https://home-dev.felo.me';
// const meetUrl = 'https://meet-dev.felo.me';
// const imUrl = 'https://im-dev.felo.me';
const urls = [ const urls = [
// 301 检测 // 301 检测
{ {
@ -16,30 +22,68 @@ const urls = [
}, },
{ {
url: `${homeUrl}/pricing`, url: `${homeUrl}/pricing`,
code: 301, code: 200,
comment: '跳转检测', comment: '不跳转检测',
location: `${meetUrl}/pricing`, },
{
url: `${homeUrl}/${locale}/pricing`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/security`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/${locale}/security`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/translator`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/${locale}/translator`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/download`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/${locale}/download`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/contact`,
code: 200,
comment: '不跳转检测',
},
{
url: `${homeUrl}/${locale}/contact`,
code: 200,
comment: '不跳转检测',
}, },
// {
// url: `${homeUrl}/download`,
// code: 301,
// comment: '跳转检测(可不做',
// location: `${meetUrl}/download`,
// },
// {
// url: `${homeUrl}/contact`,
// code: 301,
// comment: '跳转检测(可不做',
// location: `${meetUrl}/contact`,
// },
// {
// url: `${homeUrl}/security`,
// code: 301,
// comment: '跳转检测(可不做',
// location: `${imUrl}/security`,
// },
// Meet // Meet
{
url: `${meetUrl}`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '会议首页,命中官网',
},
{
url: `${meetUrl}/home`,
code: 200,
matcher: /You need to enable/,
comment: '会议系统,命中系统'
},
{ {
url: `${meetUrl}/contact`, url: `${meetUrl}/contact`,
code: 200, code: 200,
@ -47,7 +91,7 @@ const urls = [
comment: '联系我们', comment: '联系我们',
}, },
{ {
url: `${meetUrl}/zh-TW/contact`, url: `${meetUrl}/${locale}/contact`,
code: 200, code: 200,
matcher: /\/homepage\/umi.js/, matcher: /\/homepage\/umi.js/,
comment: '联系我们(限定语言)', comment: '联系我们(限定语言)',
@ -59,7 +103,7 @@ const urls = [
comment: '收费', comment: '收费',
}, },
{ {
url: `${meetUrl}/zh-TW/pricing`, url: `${meetUrl}/${locale}/pricing`,
code: 200, code: 200,
matcher: /\/homepage\/umi.js/, matcher: /\/homepage\/umi.js/,
comment: '收费(限定语言)', comment: '收费(限定语言)',
@ -71,17 +115,11 @@ const urls = [
comment: '下载', comment: '下载',
}, },
{ {
url: `${meetUrl}/zh-TW/download`, url: `${meetUrl}/${locale}/download`,
code: 200, code: 200,
matcher: /\/homepage\/umi.js/, matcher: /\/homepage\/umi.js/,
comment: '下载(限定语言)', comment: '下载(限定语言)',
}, },
{
url: `${meetUrl}/home`,
code: 200,
matcher: /You need to enable/,
comment: '会议首页'
},
// IM // IM
{ {
@ -91,7 +129,19 @@ const urls = [
comment: '安全', comment: '安全',
}, },
{ {
url: `${imUrl}/zh-TW/security`, url: `${imUrl}/${locale}/security`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '安全(限定语言)',
},
{
url: `${imUrl}/contact`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '安全',
},
{
url: `${imUrl}/${locale}/contact`,
code: 200, code: 200,
matcher: /\/homepage\/umi.js/, matcher: /\/homepage\/umi.js/,
comment: '安全(限定语言)', comment: '安全(限定语言)',
@ -113,22 +163,23 @@ const promises = urls.map((item, index) => {
resolve({ resolve({
url: urlItem.url, url: urlItem.url,
status: status === urlItem.code ? '匹配' : '不匹配', status: status === urlItem.code ? '✅' : '❌',
statusShould: urlItem.code, statusShould: urlItem.code,
statusActual: status, statusActual: status,
locationShould: urlItem.location || '/', locationShould: urlItem.location || '/',
locationActual: res.headers.location || '/', locationActual: res.headers.location || '/',
location: urlItem.location ? ( location: urlItem.location ? (
urlItem.location === res.headers.location ? '匹配' : '不匹配' urlItem.location === res.headers.location ? '✅' : '❌'
) : '/', ) : '/',
match: urlItem.matcher ? ( match: urlItem.matcher ? (
chunkRes.match(urlItem.matcher) ? '内容匹配' : '内容不匹配' chunkRes.match(urlItem.matcher) ? '✅' : '❌'
) : '/', ) : '/',
comment: urlItem.comment, comment: urlItem.comment,
}); });
}); });
res.on('error', () => { res.on('error', (err) => {
console.log(err, item.url);
reject(); reject();
}) })
}); });