From bac04587b86868a204a4af8d0d12e9fe730b5347 Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Sun, 23 Oct 2022 13:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(subscriptions):=20negative?= =?UTF-8?q?=20usage=20flow?= 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