From 7e2109dc685f7d71db74259086f8ac1b0016a0f0 Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 29 Dec 2024 21:03:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20url=20=E5=90=8C=E6=97=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8D=95=E6=9D=A1=E6=9C=AC=E5=9C=B0=E8=8A=82=E7=82=B9=E5=86=85?= =?UTF-8?q?=E5=AE=B9,=20=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=8C=87=E5=AE=9A=E8=BE=93=E5=87=BA=E7=9B=AE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/download.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index d42a03d..c9ccbc6 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.15.6", + "version": "2.15.8", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index c85bc72..4c9fc84 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -18,6 +18,11 @@ export default function register($app) { $app.get('/download/collection/:name', downloadCollection); $app.get('/download/:name', downloadSubscription); + $app.get('/download/:name/:target', async (req, res) => { + req.query.target = req.params.target; + $.info(`使用路由指定目标: ${req.params.target}`); + await downloadSubscription(req, res); + }); $app.get( '/download/collection/:name/api/v1/server/details', async (req, res) => { @@ -98,6 +103,14 @@ async function downloadSubscription(req, res) { if (url) { url = decodeURIComponent(url); $.info(`指定远程订阅 URL: ${url}`); + if (!/^https?:\/\//.test(url)) { + content = url; + $.info(`URL 不是链接,视为本地订阅`); + } + } + if (content) { + content = decodeURIComponent(content); + $.info(`指定本地订阅: ${content}`); } if (proxy) { proxy = decodeURIComponent(proxy); @@ -107,10 +120,7 @@ async function downloadSubscription(req, res) { ua = decodeURIComponent(ua); $.info(`指定远程订阅 User-Agent: ${ua}`); } - if (content) { - content = decodeURIComponent(content); - $.info(`指定本地订阅: ${content}`); - } + if (mergeSources) { mergeSources = decodeURIComponent(mergeSources); $.info(`指定合并来源: ${mergeSources}`);