chore: Felo 相关脚本

This commit is contained in:
2026-09-10 10:48:32 +08:00
parent 168fc28d48
commit b9682de64a
2 changed files with 172 additions and 0 deletions
+191
View File
@@ -0,0 +1,191 @@
// 公司官网检测链接跳转和有效性的脚本
const https = require('https');
const locale = 'zh-TW';
const homeUrl = 'https://felo.me';
const meetUrl = 'https://meet.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 = [
// 301 检测
{
url: `${homeUrl}/meeting`,
code: 301,
comment: '跳转检测',
location: `${meetUrl}/`,
},
{
url: `${homeUrl}/pricing`,
code: 200,
comment: '不跳转检测',
},
{
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: '不跳转检测',
},
// Meet
{
url: `${meetUrl}`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '会议首页,命中官网',
},
{
url: `${meetUrl}/home`,
code: 200,
matcher: /You need to enable/,
comment: '会议系统,命中系统'
},
{
url: `${meetUrl}/contact`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '联系我们',
},
{
url: `${meetUrl}/${locale}/contact`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '联系我们(限定语言)',
},
{
url: `${meetUrl}/pricing`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '收费',
},
{
url: `${meetUrl}/${locale}/pricing`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '收费(限定语言)',
},
{
url: `${meetUrl}/download`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '下载',
},
{
url: `${meetUrl}/${locale}/download`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '下载(限定语言)',
},
// IM
{
url: `${imUrl}/security`,
code: 200,
matcher: /\/homepage\/umi.js/,
comment: '安全',
},
{
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,
matcher: /\/homepage\/umi.js/,
comment: '安全(限定语言)',
},
];
const promises = urls.map((item, index) => {
return new Promise((resolve, reject) => {
https.get(item.url, (res) => {
let chunkRes;
res.on('data', (chunk) => {
chunkRes = chunk.toString();
})
res.on('end', () => {
const urlItem = urls[index];
const status = res.statusCode;
resolve({
url: urlItem.url,
status: status === urlItem.code ? '✅' : '❌',
statusShould: urlItem.code,
statusActual: status,
locationShould: urlItem.location || '/',
locationActual: res.headers.location || '/',
location: urlItem.location ? (
urlItem.location === res.headers.location ? '✅' : '❌'
) : '/',
match: urlItem.matcher ? (
chunkRes.match(urlItem.matcher) ? '✅' : '❌'
) : '/',
comment: urlItem.comment,
});
});
res.on('error', (err) => {
console.log(err, item.url);
reject();
})
});
});
});
Promise.all(promises).then(async (res) => {
console.table(res);
});
+172
View File
@@ -0,0 +1,172 @@
// 公司官网检测链接跳转和有效性的脚本
const http = require('http');
const https = require('http');
const locale = 'zh-TW';
const homeUrl = 'http://localhost:3003';
// const homeUrl = 'https://felo.me';
const urls = [
{
url: `${homeUrl}`,
code: 307,
comment: '跳转-首页',
location: `/translator`,
},
{
url: `${homeUrl}/zh-TW`,
code: 307,
comment: '跳转-仅语言',
location: `/zh-TW/translator`,
},
{
url: `${homeUrl}/en`,
code: 307,
comment: '跳转-仅语言-默认',
location: `/translator`,
},
{
url: `${homeUrl}/en`,
code: 307,
comment: '跳转-仅语言-双参数相同',
location: `/translator`,
headers: {
'accept-language': 'en-US',
},
},
{
url: `${homeUrl}/en`,
code: 307,
comment: '跳转-仅语言-双参数不相同 A',
location: `/translator`,
headers: {
'accept-language': 'zh-TW',
},
},
{
url: `${homeUrl}/ja`,
code: 307,
comment: '跳转-仅语言-双参数不相同 B',
location: `/ja/translator`,
headers: {
'accept-language': 'zh-TW',
},
},
{
url: `${homeUrl}/translator`,
code: 200,
comment: '无跳转-业务-默认语言',
},
{
url: `${homeUrl}/translator`,
code: 200,
comment: '无跳转-业务-Headers语言-同默认语言',
headers: {
'accept-language': 'en-US',
},
},
{
url: `${homeUrl}/translator`,
code: 307,
location: '/ru/translator',
comment: '跳转-业务-Headers语言-非默认语言',
headers: {
'accept-language': 'ru',
},
},
{
url: `${homeUrl}/en/translator`,
code: 307,
location: '/translator',
comment: '跳转-业务-地址栏语言-默认',
},
{
url: `${homeUrl}/id/translator`,
code: 200,
comment: '无跳转-业务-地址栏语言-非默认',
},
{
url: `${homeUrl}/zh-TW/translator`,
code: 200,
comment: '无跳转-业务-双参数不相同 A',
headers: {
'accept-language': 'ja',
},
},
{
url: `${homeUrl}/it/translator`,
code: 200,
comment: '无跳转-业务-双参数不相同 B',
headers: {
'accept-language': 'zh-CN',
},
},
{
url: `${homeUrl}/ja-JP`,
code: 307,
comment: '临时跳转-jaJP-首页',
location: '/ja/translator',
},
{
url: `${homeUrl}/ja-JP/translator`,
code: 307,
comment: '临时跳转-jaJP-业务',
location: '/ja/translator',
headers: {
'accept-language': 'zh-CN',
},
},
];
const promises = urls.map((item, index) => {
const url = new URL(item.url);
return new Promise((resolve, reject) => {
const options = {
hostname: url.hostname,
port: url.port,
method: 'GET',
path: url.pathname,
headers: item.headers,
};
http.get(options, (res) => {
let chunkRes;
res.on('data', (chunk) => {
chunkRes = chunk.toString();
})
res.on('end', () => {
const urlItem = urls[index];
const status = res.statusCode;
resolve({
comment: urlItem.comment,
url: urlItem.url,
status: status === urlItem.code ? '✅' : '❌',
// statusShould: urlItem.code,
statusActual: status,
location: urlItem.location ? (
urlItem.location === res.headers.location ? '✅' : '❌'
) : '/',
// locationShould: urlItem.location || '',
locationActual: res.headers.location || '',
});
});
res.on('error', (err) => {
console.log(err, item.url);
reject();
})
}).on('error', (err) => {
console.log('err', err);
});
});
});
Promise.all(promises).then(async (res) => {
console.table(res);
});