From c7c9b21f798d896eb72271e01a2b8cd5e4eb4dba Mon Sep 17 00:00:00 2001 From: xream Date: Mon, 4 Aug 2025 10:48:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AC=E5=9C=B0=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=B7=B7=E5=86=99=E5=8D=95=E8=A1=8C=20YAML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/parsers/index.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index 9aa478d..f3d809d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.20.0", + "version": "2.20.1", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index f2d37d2..2e83b0d 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -13,6 +13,7 @@ import getQXParser from './peggy/qx'; import getTrojanURIParser from './peggy/trojan-uri'; import $ from '@/core/app'; import JSON5 from 'json5'; +import YAML from '@/utils/yaml'; import { Base64 } from 'js-base64'; @@ -1130,15 +1131,21 @@ function URI_Trojan() { function Clash_All() { const name = 'Clash Parser'; const test = (line) => { + let proxy; try { - JSON5.parse(line); + proxy = JSON5.parse(line); } catch (e) { - return false; + proxy = YAML.parse(line); } - return true; + return !!proxy?.type; }; const parse = (line) => { - const proxy = JSON5.parse(line); + let proxy; + try { + proxy = JSON5.parse(line); + } catch (e) { + proxy = YAML.parse(line); + } if ( ![ 'anytls',