♻️ refactor(substore): 优化重命名脚本中的线路标签与冗余尾号清洗逻辑

This commit is contained in:
Orion
2026-06-03 13:32:40 +08:00
parent ce9fac0504
commit 6c1e055281
3 changed files with 15 additions and 10 deletions
+6 -2
View File
@@ -33,7 +33,7 @@ async function operator(proxies) {
const featureMap = {
"GTM 0.5x": "三网",
"GTM": "三网",
"CT": "CF",
"CT": "CFW",
"S1": "广移",
"S2": "广电",
"S3": "广移",
@@ -112,11 +112,15 @@ async function operator(proxies) {
// 缓存后缀匹配正则,避免循环内重复创建
const suffixRegex = /\s*-\s*(SNTP.*)$/i;
const normalizeSntpSuffixSpacing = proxyName => proxyName.replace(suffixRegex, '-$1');
const normalizeCloudflareLabel = proxyName => proxyName
.replace(/\s*\[(?:CF|Cloudflare)]\s*/gi, ' [CFW] ')
.replace(/\s{2,}/g, ' ')
.trim();
// 3. 执行节点遍历与注入
return proxies.map(proxy => {
if (typeof proxy.name !== 'string') return proxy;
let proxyName = normalizeSntpSuffixSpacing(proxy.name);
let proxyName = normalizeCloudflareLabel(normalizeSntpSuffixSpacing(proxy.name));
// 单次复合正则扫描提取
const featureMatch = proxyName.match(featureRegex);