✨ feat(sntp-rename): 增加专线提供商名称首字母缩写逻辑
This commit is contained in:
+10
-3
@@ -26,7 +26,7 @@ function operator(proxies) {
|
||||
// 已经由标签表达含义的特征码,会自动从展示名中移除。
|
||||
// 维护方式:只改 featureMap 即可,这里不需要单独配置隐藏词。
|
||||
// 示例:🇭🇰 HK06-GTM Oilguy专线 [三网] - SNTP
|
||||
// 输出:🇭🇰 HK 06 Oilguy专线 [三网]-SNTP
|
||||
// 输出:🇭🇰 HK 06 O专线 [三网]-SNTP
|
||||
// ==============================================
|
||||
|
||||
|
||||
@@ -74,6 +74,13 @@ function operator(proxies) {
|
||||
})
|
||||
.replace(/(\b[A-Z]{2} \d{2})-(?=\d+(?:\.\d+)?x\b)/g, '$1 ');
|
||||
|
||||
const abbreviateDedicatedLineProvider = proxyName => proxyName.replace(
|
||||
/\b([A-Za-z])[A-Za-z]*\s*专线/g,
|
||||
(match, providerInitial) => `${providerInitial.toUpperCase()}专线`
|
||||
);
|
||||
|
||||
const normalizeDisplayName = proxyName => abbreviateDedicatedLineProvider(normalizeRegionSequence(proxyName));
|
||||
|
||||
// 2. 动态构建复合正则表达式 (核心引擎)
|
||||
// 按字符串长度降序排序,彻底解决 "短路匹配" (Short-Circuit) 问题
|
||||
const sortedFeatureKeywords = [...featureKeywords].sort(
|
||||
@@ -100,7 +107,7 @@ function operator(proxies) {
|
||||
// 单次复合正则扫描提取
|
||||
const featureMatch = proxyName.match(featureRegex);
|
||||
if (!featureMatch) {
|
||||
proxy.name = normalizeRegionSequence(proxyName);
|
||||
proxy.name = normalizeDisplayName(proxyName);
|
||||
return proxy; // 未命中配置库,仅保留缩写结果后放行
|
||||
}
|
||||
|
||||
@@ -110,7 +117,7 @@ function operator(proxies) {
|
||||
|
||||
if (!injectedFeatureLabel) return proxy; // 兜底安全校验
|
||||
|
||||
proxyName = normalizeRegionSequence(stripHiddenFeatureKeywords(proxyName));
|
||||
proxyName = normalizeDisplayName(stripHiddenFeatureKeywords(proxyName));
|
||||
|
||||
// 格式化组装与幂等校验 (防重复注入 Bug)
|
||||
const formattedFeatureLabel = ` [${injectedFeatureLabel}]`;
|
||||
|
||||
Reference in New Issue
Block a user