feat: /api/sub/flow/:name 接口支持指定远程订阅 url(可携带订阅 url 支持的参数, 例如 flowUserAgent)

This commit is contained in:
xream 2024-06-10 13:24:06 +08:00
parent bf642ce0e6
commit 913638a233
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.334",
"version": "2.14.335",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@ -34,6 +34,11 @@ export default function register($app) {
async function getFlowInfo(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let { url } = req.query;
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程订阅 URL: ${url}`);
}
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
if (!sub) {
@ -68,8 +73,8 @@ async function getFlowInfo(req, res) {
return;
}
try {
let url =
`${sub.url}`
url =
`${url || sub.url}`
.split(/[\r\n]+/)
.map((i) => i.trim())
.filter((i) => i.length)?.[0] || '';