fix: 兼容空的订阅链接

This commit is contained in:
xream 2024-06-09 01:42:40 +08:00
parent 1ecac9da92
commit bf642ce0e6
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
6 changed files with 19 additions and 16 deletions

View File

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

View File

@ -83,7 +83,7 @@ async function processFn(proxies, operators = [], targetPlatform, source) {
const { mode, content } = item.args; const { mode, content } = item.args;
if (mode === 'link') { if (mode === 'link') {
let noCache; let noCache;
let url = content; let url = content || '';
if (url.endsWith('#noCache')) { if (url.endsWith('#noCache')) {
url = url.replace(/#noCache$/, ''); url = url.replace(/#noCache$/, '');
noCache = true; noCache = true;

View File

@ -123,10 +123,11 @@ async function downloadSubscription(req, res) {
['localFirst', 'remoteFirst'].includes(sub.mergeSources) ['localFirst', 'remoteFirst'].includes(sub.mergeSources)
) { ) {
try { try {
url = `${url || sub.url}` url =
`${url || sub.url}`
.split(/[\r\n]+/) .split(/[\r\n]+/)
.map((i) => i.trim()) .map((i) => i.trim())
.filter((i) => i.length)?.[0]; .filter((i) => i.length)?.[0] || '';
let $arguments = {}; let $arguments = {};
const rawArgs = url.split('#'); const rawArgs = url.split('#');
@ -283,10 +284,11 @@ async function downloadCollection(req, res) {
['localFirst', 'remoteFirst'].includes(sub.mergeSources) ['localFirst', 'remoteFirst'].includes(sub.mergeSources)
) { ) {
try { try {
let url = `${sub.url}` let url =
`${sub.url}`
.split(/[\r\n]+/) .split(/[\r\n]+/)
.map((i) => i.trim()) .map((i) => i.trim())
.filter((i) => i.length)?.[0]; .filter((i) => i.length)?.[0] || '';
let $arguments = {}; let $arguments = {};
const rawArgs = url.split('#'); const rawArgs = url.split('#');

View File

@ -68,10 +68,11 @@ async function getFlowInfo(req, res) {
return; return;
} }
try { try {
let url = `${sub.url}` let url =
`${sub.url}`
.split(/[\r\n]+/) .split(/[\r\n]+/)
.map((i) => i.trim()) .map((i) => i.trim())
.filter((i) => i.length)?.[0]; .filter((i) => i.length)?.[0] || '';
let $arguments = {}; let $arguments = {};
const rawArgs = url.split('#'); const rawArgs = url.split('#');

View File

@ -15,7 +15,7 @@ import $ from '@/core/app';
const tasks = new Map(); const tasks = new Map();
export default async function download( export default async function download(
rawUrl, rawUrl = '',
ua, ua,
timeout, timeout,
proxy, proxy,

View File

@ -11,7 +11,7 @@ export function getFlowField(headers) {
return headers[subkey]; return headers[subkey];
} }
export async function getFlowHeaders(rawUrl, ua, timeout, proxy, flowUrl) { export async function getFlowHeaders(rawUrl, ua, timeout, proxy, flowUrl) {
let url = flowUrl || rawUrl; let url = flowUrl || rawUrl || '';
let $arguments = {}; let $arguments = {};
const rawArgs = url.split('#'); const rawArgs = url.split('#');
url = url.split('#')[0]; url = url.split('#')[0];