Browse Source

feat: support `text/plain` http request block

Ahmad Kholid 2 years ago
parent
commit
a4c81fe42a
2 changed files with 4 additions and 0 deletions
  1. 1 0
      src/utils/shared.js
  2. 3 0
      src/utils/webhookUtil.js

+ 1 - 0
src/utils/shared.js

@@ -1464,6 +1464,7 @@ export const excludeOnError = [
 ];
 
 export const contentTypes = [
+  { name: 'text/plain', value: 'text' },
   { name: 'application/json', value: 'json' },
   { name: 'multipart/form-data', value: 'form-data' },
   { name: 'application/x-www-form-urlencoded', value: 'form' },

+ 3 - 0
src/utils/webhookUtil.js

@@ -1,6 +1,8 @@
 import { parseJSON, isWhitespace } from './helper';
 
 const renderContent = (content, contentType) => {
+  if (contentType === 'text/plain') return content;
+
   const renderedJson = parseJSON(content, new Error('invalid-body'));
 
   if (renderedJson instanceof Error) throw renderedJson;
@@ -38,6 +40,7 @@ const filterHeaders = (headers) => {
 };
 
 const contentTypes = {
+  text: 'text/plain',
   json: 'application/json',
   'form-data': 'multipart/form-data',
   form: 'application/x-www-form-urlencoded',