whistle.pastekitlab 1.7.7 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +16 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -248,18 +248,28 @@ module.exports = (server, options) => {
248
248
 
249
249
  // 转换响应数据为 Buffer 或字符串
250
250
  let responseBody;
251
+ let responseBodyForNotification = null;
252
+
251
253
  if (Buffer.isBuffer(response.data)) {
252
254
  responseBody = response.data;
255
+ responseBodyForNotification = bufferToString(response.data);
253
256
  } else if (typeof response.data === 'string') {
254
257
  responseBody = response.data;
258
+ responseBodyForNotification = response.data;
255
259
  } else if (typeof response.data === 'object') {
256
260
  try {
257
- responseBody = JSON.stringify(response.data);
261
+ const jsonStr = JSON.stringify(response.data);
262
+ responseBody = jsonStr;
263
+ responseBodyForNotification = jsonStr;
258
264
  } catch (e) {
259
- responseBody = String(response.data);
265
+ const str = String(response.data);
266
+ responseBody = str;
267
+ responseBodyForNotification = str;
260
268
  }
261
269
  } else {
262
- responseBody = String(response.data || '');
270
+ const str = String(response.data || '');
271
+ responseBody = str;
272
+ responseBodyForNotification = str;
263
273
  }
264
274
 
265
275
  // 确保 responseBody 是有效的字符串或 Buffer
@@ -275,15 +285,9 @@ module.exports = (server, options) => {
275
285
  ...requestData,
276
286
  statusCode: response.status,
277
287
  responseHeaders: {...response.headers},
278
- responseBody: bufferToString(
279
- typeof response.data === 'string'
280
- ? Buffer.from(response.data)
281
- : Buffer.from(JSON.stringify(response.data))
282
- ),
283
- responseBodyBase64: (
284
- typeof response.data === 'string'
285
- ? Buffer.from(response.data)
286
- : Buffer.from(JSON.stringify(response.data))
288
+ responseBody: responseBodyForNotification,
289
+ responseBodyBase64: Buffer.from(
290
+ typeof responseBody === 'string' ? responseBody : responseBody.toString()
287
291
  ).toString('base64'),
288
292
  duration
289
293
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.pastekitlab",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "Whistle plugin for PasteKit Lab - Intercepts requests and sends them to requestlistviewer via WebSocket",
5
5
  "main": "index.js",
6
6
  "scripts": {