mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-29 07:50:33 +00:00
feat: 调整 normalizeClashYaml 处理方式
This commit is contained in:
5 files changed
+14
-4
No files matched your search
@@ -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) => {
|
||||
|
||||
@@ -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 下载文件失败`,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user