MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / stabilizeResponseOutput

Function stabilizeResponseOutput

tests/utils.ts:404–439  ·  view source on GitHub ↗
(text: unknown)

Source from the content-addressed store, hash-verified

402}
403
404export function stabilizeResponseOutput(text: unknown): string {
405 if (typeof text !== 'string') {
406 throw new Error('Input must be string');
407 }
408 let output = text;
409 const dateRegEx = /.{3}, \d{2} .{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z]{3}/g;
410 output = output.replaceAll(dateRegEx, '<long date>');
411
412 const localhostRegEx = /localhost:\d{5}/g;
413 output = output.replaceAll(localhostRegEx, 'localhost:<port>');
414
415 const loopbackAddress = /127.0.0.1:\d{5}/g;
416 output = output.replaceAll(loopbackAddress, '127.0.0.1:<port>');
417
418 const userAgentRegEx = /user-agent:.*\n/g;
419 output = output.replaceAll(userAgentRegEx, 'user-agent:<user-agent>\n');
420
421 const chUaRegEx = /sec-ch-ua:"Chromium";v="\d{3}"/g;
422 output = output.replaceAll(chUaRegEx, 'sec-ch-ua:"Chromium";v="<version>"');
423
424 // sec-ch-ua-platform:"Linux"
425 const chUaPlatformRegEx = /sec-ch-ua-platform:"[a-zA-Z]*"/g;
426 output = output.replaceAll(chUaPlatformRegEx, 'sec-ch-ua-platform:"<os>"');
427
428 const savedSnapshot = /Saved snapshot to (.*)/g;
429 output = output.replaceAll(savedSnapshot, 'Saved snapshot to <file>');
430
431 const acceptLanguageRegEx = /accept-language:.*\n/g;
432 output = output.replaceAll(acceptLanguageRegEx, 'accept-language:<lang>\n');
433
434 // Stabilize URL-encoded file paths
435 const fileUriRegEx = /file%3A%2F%2F%2F[^)\n]+/g;
436 output = output.replaceAll(fileUriRegEx, '<file-path>');
437
438 return output;
439}
440
441export function getMockAggregatedIssue(): sinon.SinonStubbedInstance<DevTools.AggregatedIssue> {
442 const mockAggregatedIssue = sinon.createStubInstance(

Callers 4

stabilizeFunction · 0.85
console.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected