diff --git a/backend/package.json b/backend/package.json index 21f4cc95e..63b779105 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.297", + "version": "2.14.298", "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 b5a5d33b6..984f07a31 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -181,11 +181,21 @@ function createSubscription(req, res) { function getSubscription(req, res) { let { name } = req.params; + let { raw } = req.query; name = decodeURIComponent(name); const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); if (sub) { - success(res, sub); + if (raw) { + res.set('content-type', 'application/json') + .set( + 'content-disposition', + `attachment; filename="${encodeURIComponent(name)}.json"`, + ) + .send(JSON.stringify(sub)); + } else { + success(res, sub); + } } else { failed( res,