From 510534ee0cc5bc0e90ac71bd4cb4d9c0763fe6b2 Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 16 Apr 2024 10:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20text/plain=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B6=88=E6=81=AF=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 2 +- sample/notify.js | 2 +- sample/notify.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index 318aa041..77fef6bc 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -399,7 +399,7 @@ export function parseBody( valueFormatFn?: (v: string) => string, ) { if (contentType === 'text/plain' || !body) { - return body; + return valueFormatFn && body ? valueFormatFn(body) : body; } const parsed = parseString(body, valueFormatFn); diff --git a/sample/notify.js b/sample/notify.js index 9d17e16a..9351cefe 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -1379,7 +1379,7 @@ function parseHeaders(headers) { function parseBody(body, contentType, valueFormatFn) { if (contentType === 'text/plain' || !body) { - return body; + return valueFormatFn && body ? valueFormatFn(body) : body; } const parsed = parseString(body, valueFormatFn); diff --git a/sample/notify.py b/sample/notify.py index 2bd0f7ae..0e40fcbc 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -766,7 +766,7 @@ def parse_string(input_string, value_format_fn=None): def parse_body(body, content_type, value_format_fn=None): if not body or content_type == "text/plain": - return body + return value_format_fn(body) if value_format_fn and body else body parsed = parse_string(body, value_format_fn)