From 1bc44ccde867f9e17910d25111280d9a2bf1942e Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 16 Jan 2024 08:11:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E9=98=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=AF=E4=BD=BF=E7=94=A8=E6=A0=87=E5=87=86=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=20#noCache&noFlow=20=E6=88=96=20=E4=BA=95?= =?UTF-8?q?=E5=8F=B7=E9=99=84=E5=8A=A0=20#noCache#noFlow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/utils/download.js | 4 +++- backend/src/utils/flow.js | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/src/utils/download.js b/backend/src/utils/download.js index 5274c72..9b59459 100644 --- a/backend/src/utils/download.js +++ b/backend/src/utils/download.js @@ -9,9 +9,11 @@ import $ from '@/core/app'; const tasks = new Map(); -export default async function download(url, ua, timeout) { +export default async function download(rawUrl, ua, timeout) { let $arguments = {}; + let url = rawUrl.replace(/#noFlow$/, ''); const rawArgs = url.split('#'); + url = url.split('#')[0]; if (rawArgs.length > 1) { try { // 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}` diff --git a/backend/src/utils/flow.js b/backend/src/utils/flow.js index c0195ac..125abe8 100644 --- a/backend/src/utils/flow.js +++ b/backend/src/utils/flow.js @@ -9,12 +9,11 @@ export function getFlowField(headers) { )[0]; return headers[subkey]; } -export async function getFlowHeaders(url, ua, timeout) { - if (url.endsWith('#noFlow')) { - return; - } +export async function getFlowHeaders(rawUrl, ua, timeout) { + let url = rawUrl; let $arguments = {}; const rawArgs = url.split('#'); + url = url.split('#')[0]; if (rawArgs.length > 1) { try { // 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}` @@ -31,6 +30,9 @@ export async function getFlowHeaders(url, ua, timeout) { } } } + if ($arguments?.noFlow) { + return; + } const cached = headersResourceCache.get(url); let flowInfo; if (!$arguments?.noCache && cached) {