From 5de35c7720ac885afddda5a37c99773693b056e5 Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Tue, 25 Oct 2022 00:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(subscriptions):=20negative?= =?UTF-8?q?=20usage=20flow=20(#175)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/subscriptions.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index 3a86999..8e73beb 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.13.4", + "version": "2.13.5", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index aeb184e..e192111 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -66,8 +66,12 @@ async function getFlowInfo(req, res) { } // unit is KB - const upload = Number(flowHeaders.match(/upload=(\d+)/)[1]); - const download = Number(flowHeaders.match(/download=(\d+)/)[1]); + const uploadMatch = flowHeaders.match(/upload=(-?)(\d+)/) + const upload = Number(uploadMatch[1] + uploadMatch[2]); + + const downloadMatch = flowHeaders.match(/download=(-?)(\d+)/) + const download = Number(downloadMatch[1] + downloadMatch[2]); + const total = Number(flowHeaders.match(/total=(\d+)/)[1]); // optional expire timestamp