feat: 调整 normalizeClashYaml 处理方式

This commit is contained in:
xream committed 2026-03-22 06:24:03 +08:00
1 parent 2c1d0bc0d9
commit 185c9268c9
5 files changed
+14 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.21.51",
"version": "2.21.52",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
@@ -11,6 +11,13 @@ export function normalizeClashYaml(raw) {
return raw;
}
try {
const content = safeLoad(raw);
if (!Array.isArray(content.proxies) || content.proxies.length === 0)
return raw;
} catch (e) {
return raw;
}
// 防止 VLESS 节点 reality-opts 里的 short-id 被 YAML 标量推断成数字
// 例如 08 / 0088 在部分内核重新解析时会触发 invalid REALITY short ID
return raw.replace(/short-id:([ \t]*[^#\n,}]*)/g, (matched, value) => {
+1 -2
View File
@@ -9,7 +9,6 @@ import {
InternalServerError,
} from '@/restful/errors';
import { produceArtifact } from '@/restful/sync';
import { normalizeClashYaml } from '@/core/proxy-utils/preprocessors';
import { formatDateTime } from '@/utils';
export default function register($app) {
@@ -205,7 +204,7 @@ async function getFile(req, res, next) {
if (output?.$options?._res?.status) {
res.status(output.$options._res.status);
}
res.send(normalizeClashYaml(output?.$content ?? ''));
res.send(output?.$content ?? '');
} catch (err) {
$.notify(
`🌍 Sub-Store 下载文件失败`,
+2 -1
View File
@@ -5,6 +5,7 @@ import { success, failed } from './response';
import download from '@/utils/download';
import { SUBS_KEY } from '@/constants';
import $ from '@/core/app';
import { normalizeClashYaml } from '@/core/proxy-utils/preprocessors';
export default function register($app) {
$app.post('/api/preview/sub', compareSub);
@@ -89,7 +90,7 @@ async function previewFile(req, res) {
// produce
success(res, {
original: filesContent,
processed: processed?.$content ?? '',
processed: normalizeClashYaml(processed?.$content ?? ''),
});
} catch (err) {
$.error(err.message ?? err);
+3
View File
@@ -13,6 +13,7 @@ import download from '@/utils/download';
import { ProxyUtils } from '@/core/proxy-utils';
import { RuleUtils } from '@/core/rule-utils';
import { syncToGist } from '@/restful/artifacts';
import { normalizeClashYaml } from '@/core/proxy-utils/preprocessors';
export default function register($app) {
// Initialization
@@ -596,6 +597,8 @@ async function produceArtifact({
)
: { $content: filesContent, $files: files, $options };
processed.$content = normalizeClashYaml(processed?.$content ?? '');
return (all ? processed : processed?.$content) ?? '';
}
}