diff --git a/backend/package.json b/backend/package.json index 269b89f..30b55c3 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.18.0", + "version": "2.18.1", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/collections.js b/backend/src/restful/collections.js index cdf29cb..d4482ce 100644 --- a/backend/src/restful/collections.js +++ b/backend/src/restful/collections.js @@ -63,13 +63,17 @@ function getCollection(req, res) { `sub-store_collection_${name}_${new Date() .toLocaleString('zh-CN', { year: 'numeric', - day: 'numeric', - month: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, }) - .replace(/\D/g, '')}.json`, + .replace( + /^(\d+?)\/(\d+?)\/(\d+?)\s*?(\d+?):(\d+?):(\d+?)$/, + '$1-$2-$3_$4-$5-$6', + )}.json`, )}"`, ) .send(JSON.stringify(collection)); diff --git a/backend/src/restful/file.js b/backend/src/restful/file.js index dbbf067..467c986 100644 --- a/backend/src/restful/file.js +++ b/backend/src/restful/file.js @@ -213,13 +213,17 @@ function getWholeFile(req, res) { `sub-store_file_${name}_${new Date() .toLocaleString('zh-CN', { year: 'numeric', - day: 'numeric', - month: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, }) - .replace(/\D/g, '')}.json`, + .replace( + /^(\d+?)\/(\d+?)\/(\d+?)\s*?(\d+?):(\d+?):(\d+?)$/, + '$1-$2-$3_$4-$5-$6', + )}.json`, )}"`, ) .send(JSON.stringify(file)); diff --git a/backend/src/restful/miscs.js b/backend/src/restful/miscs.js index 7d521d9..028e07d 100644 --- a/backend/src/restful/miscs.js +++ b/backend/src/restful/miscs.js @@ -31,13 +31,17 @@ export default function register($app) { `sub-store_data_${new Date() .toLocaleString('zh-CN', { year: 'numeric', - day: 'numeric', - month: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, }) - .replace(/\D/g, '')}.json`, + .replace( + /^(\d+?)\/(\d+?)\/(\d+?)\s*?(\d+?):(\d+?):(\d+?)$/, + '$1-$2-$3_$4-$5-$6', + )}.json`, )}"`, ) .send( diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index d8425f6..1b0e162 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -268,13 +268,17 @@ function getSubscription(req, res) { `sub-store_subscription_${name}_${new Date() .toLocaleString('zh-CN', { year: 'numeric', - day: 'numeric', - month: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false, }) - .replace(/\D/g, '')}.json`, + .replace( + /^(\d+?)\/(\d+?)\/(\d+?)\s*?(\d+?):(\d+?):(\d+?)$/, + '$1-$2-$3_$4-$5-$6', + )}.json`, )}"`, ) .send(JSON.stringify(sub)); diff --git a/backend/src/vendor/open-api.js b/backend/src/vendor/open-api.js index c01947e..e9cd8fa 100644 --- a/backend/src/vendor/open-api.js +++ b/backend/src/vendor/open-api.js @@ -373,6 +373,17 @@ export function HTTP(defaultOptions = { baseURL: '' }) { headersTimeout: opts.timeout, }; try { + const url = new URL(opts.url); + if (url.username || url.password) { + opts.headers = { + ...(opts.headers || {}), + Authorization: `Basic ${Buffer.from( + `${url.username || ''}:${ + url.password || '' + }`, + ).toString('base64')}`, + }; + } const response = await request(opts.url, { ...opts, method: method.toUpperCase(),