From 7a35173f54bfeb1234e360e1a7510352aa9856b4 Mon Sep 17 00:00:00 2001 From: Orion Date: Wed, 3 Jun 2026 11:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20fix(substore):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=20normalizeRegionSequence=20=E5=87=BD=E6=95=B0=E4=BB=A5?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=E5=9C=B0=E5=8C=BA=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- substore/sntp-rename.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/substore/sntp-rename.js b/substore/sntp-rename.js index 3d13874..53ed959 100644 --- a/substore/sntp-rename.js +++ b/substore/sntp-rename.js @@ -26,7 +26,7 @@ function operator(proxies) { // 已经由标签表达含义的特征码,会自动从展示名中移除。 // 维护方式:只改 featureMap 即可,这里不需要单独配置隐藏词。 // 示例:🇭🇰 HK06-GTM Oilguy专线 [三网] - SNTP - // 输出:🇭🇰 HK06 Oilguy专线 [三网]-SNTP + // 输出:🇭🇰 HK 06 Oilguy专线 [三网]-SNTP // ============================================== @@ -68,6 +68,12 @@ function operator(proxies) { .replace(/^-+|-+$/g, '') .trim(); + const normalizeRegionSequence = proxyName => proxyName + .replace(/(^|\s)([A-Z]{2})[-\s]?(\d{1,2})(?=$|[\s-])/g, (match, prefix, regionCode, sequenceNumber) => { + return `${prefix}${regionCode} ${sequenceNumber.padStart(2, '0')}`; + }) + .replace(/(\b[A-Z]{2} \d{2})-(?=\d+(?:\.\d+)?x\b)/g, '$1 '); + // 2. 动态构建复合正则表达式 (核心引擎) // 按字符串长度降序排序,彻底解决 "短路匹配" (Short-Circuit) 问题 const sortedFeatureKeywords = [...featureKeywords].sort( @@ -94,7 +100,7 @@ function operator(proxies) { // 单次复合正则扫描提取 const featureMatch = proxyName.match(featureRegex); if (!featureMatch) { - proxy.name = proxyName; + proxy.name = normalizeRegionSequence(proxyName); return proxy; // 未命中配置库,仅保留缩写结果后放行 } @@ -104,7 +110,7 @@ function operator(proxies) { if (!injectedFeatureLabel) return proxy; // 兜底安全校验 - proxyName = stripHiddenFeatureKeywords(proxyName); + proxyName = normalizeRegionSequence(stripHiddenFeatureKeywords(proxyName)); // 格式化组装与幂等校验 (防重复注入 Bug) const formattedFeatureLabel = ` [${injectedFeatureLabel}]`; @@ -123,4 +129,4 @@ function operator(proxies) { return proxy; }); -} \ No newline at end of file +}