Skip to content

Commit

Permalink
feat: 支持订阅参数 url 同时支持单条本地节点内容, 支持多一级路由指定输出目标
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Dec 29, 2024
1 parent 278beae commit 7e2109d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
18 changes: 14 additions & 4 deletions backend/src/restful/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand All @@ -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}`);
Expand Down

0 comments on commit 7e2109d

Please sign in to comment.