From 647db4c9c1bfbd24f911711280cefa1e333fa2bc Mon Sep 17 00:00:00 2001 From: Easy Date: Tue, 22 Oct 2024 15:46:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9title=E5=92=8Cdesp=20encode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/notify.ts | 4 ++-- sample/notify.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/back/services/notify.ts b/back/services/notify.ts index a229d305..ea80133d 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -152,7 +152,7 @@ export default class NotificationService { private async serverChan() { const { serverChanKey } = this.params; const matchResult = serverChanKey.match(/^sctp(\d+)t/i); - const url = matchResult + const url = matchResult && matchResult[1] ? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send` : `https://sctapi.ftqq.com/${serverChanKey}.send`; @@ -160,7 +160,7 @@ export default class NotificationService { const res: any = await got .post(url, { ...this.gotOption, - body: `title=${this.title}&desp=${this.content}`, + body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }) .json(); diff --git a/sample/notify.js b/sample/notify.js index edae3c29..9c9018ca 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -227,7 +227,7 @@ function serverNotify(text, desp) { const matchResult = PUSH_KEY.match(/^sctp(\d+)t/i); const options = { - url: matchResult + url: matchResult && matchResult[1] ? `https://${matchResult[1]}.push.ft07.com/send/${PUSH_KEY}.send` : `https://sctapi.ftqq.com/${PUSH_KEY}.send`, body: `text=${encodeURIComponent(text)}&desp=${encodeURIComponent(desp)}`,