✨ fix(substore): 新增 normalizeRegionSequence 函数以规范化地区序列格式
This commit is contained in:
@@ -26,7 +26,7 @@ function operator(proxies) {
|
|||||||
// 已经由标签表达含义的特征码,会自动从展示名中移除。
|
// 已经由标签表达含义的特征码,会自动从展示名中移除。
|
||||||
// 维护方式:只改 featureMap 即可,这里不需要单独配置隐藏词。
|
// 维护方式:只改 featureMap 即可,这里不需要单独配置隐藏词。
|
||||||
// 示例:🇭🇰 HK06-GTM Oilguy专线 [三网] - SNTP
|
// 示例:🇭🇰 HK06-GTM Oilguy专线 [三网] - SNTP
|
||||||
// 输出:🇭🇰 HK06 Oilguy专线 [三网]-SNTP
|
// 输出:🇭🇰 HK 06 Oilguy专线 [三网]-SNTP
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +68,12 @@ function operator(proxies) {
|
|||||||
.replace(/^-+|-+$/g, '')
|
.replace(/^-+|-+$/g, '')
|
||||||
.trim();
|
.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. 动态构建复合正则表达式 (核心引擎)
|
// 2. 动态构建复合正则表达式 (核心引擎)
|
||||||
// 按字符串长度降序排序,彻底解决 "短路匹配" (Short-Circuit) 问题
|
// 按字符串长度降序排序,彻底解决 "短路匹配" (Short-Circuit) 问题
|
||||||
const sortedFeatureKeywords = [...featureKeywords].sort(
|
const sortedFeatureKeywords = [...featureKeywords].sort(
|
||||||
@@ -94,7 +100,7 @@ function operator(proxies) {
|
|||||||
// 单次复合正则扫描提取
|
// 单次复合正则扫描提取
|
||||||
const featureMatch = proxyName.match(featureRegex);
|
const featureMatch = proxyName.match(featureRegex);
|
||||||
if (!featureMatch) {
|
if (!featureMatch) {
|
||||||
proxy.name = proxyName;
|
proxy.name = normalizeRegionSequence(proxyName);
|
||||||
return proxy; // 未命中配置库,仅保留缩写结果后放行
|
return proxy; // 未命中配置库,仅保留缩写结果后放行
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +110,7 @@ function operator(proxies) {
|
|||||||
|
|
||||||
if (!injectedFeatureLabel) return proxy; // 兜底安全校验
|
if (!injectedFeatureLabel) return proxy; // 兜底安全校验
|
||||||
|
|
||||||
proxyName = stripHiddenFeatureKeywords(proxyName);
|
proxyName = normalizeRegionSequence(stripHiddenFeatureKeywords(proxyName));
|
||||||
|
|
||||||
// 格式化组装与幂等校验 (防重复注入 Bug)
|
// 格式化组装与幂等校验 (防重复注入 Bug)
|
||||||
const formattedFeatureLabel = ` [${injectedFeatureLabel}]`;
|
const formattedFeatureLabel = ` [${injectedFeatureLabel}]`;
|
||||||
|
|||||||
Reference in New Issue
Block a user