MCPcopy Create free account
hub / github.com/decaporg/decap-cms / requestBodySanitizer

Function requestBodySanitizer

cypress/plugins/github.js:310–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308
309const transformRecordedData = (expectation, toSanitize) => {
310 const requestBodySanitizer = httpRequest => {
311 let body;
312 if (httpRequest.body && httpRequest.body.type === 'JSON' && httpRequest.body.json) {
313 const bodyObject =
314 typeof httpRequest.body.json === 'string'
315 ? JSON.parse(httpRequest.body.json)
316 : httpRequest.body.json;
317
318 if (bodyObject.encoding === 'base64') {
319 // sanitize encoded data
320 const decodedBody = Buffer.from(bodyObject.content, 'base64').toString('binary');
321 const sanitizedContent = sanitizeString(decodedBody, toSanitize);
322 const sanitizedEncodedContent = Buffer.from(sanitizedContent, 'binary').toString('base64');
323 bodyObject.content = sanitizedEncodedContent;
324 body = JSON.stringify(bodyObject);
325 } else {
326 body = JSON.stringify(bodyObject);
327 }
328 } else if (httpRequest.body && httpRequest.body.type === 'STRING' && httpRequest.body.string) {
329 body = httpRequest.body.string;
330 } else if (httpRequest.body) {
331 const str =
332 typeof httpRequest.body !== 'string' ? JSON.stringify(httpRequest.body) : httpRequest.body;
333 body = sanitizeString(str, toSanitize);
334 }
335 return body;
336 };
337
338 const responseBodySanitizer = (httpRequest, httpResponse) => {
339 let responseBody = null;

Callers

nothing calls this directly

Calls 2

sanitizeStringFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected