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

Function stabilizeResponseOutput

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

Source from the content-addressed store, hash-verified

432}
433
434export function stabilizeResponseOutput(text: unknown): string {
435 if (typeof text !== 'string') {
436 throw new Error('Input must be string');
437 }
438 let output = text;
439 const dateRegEx = /.{3}, \d{2} .{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z]{3}/g;
440 output = output.replaceAll(dateRegEx, '<long date>');
441
442 const localhostRegEx = /localhost:\d{5}/g;
443 output = output.replaceAll(localhostRegEx, 'localhost:<port>');
444
445 const loopbackAddress = /127.0.0.1:\d{5}/g;
446 output = output.replaceAll(loopbackAddress, '127.0.0.1:<port>');
447
448 const userAgentRegEx = /user-agent:.*\n/g;
449 output = output.replaceAll(userAgentRegEx, 'user-agent:<user-agent>\n');
450
451 const chUaRegEx = /sec-ch-ua:"Chromium";v="\d{3}"/g;
452 output = output.replaceAll(chUaRegEx, 'sec-ch-ua:"Chromium";v="<version>"');
453
454 // sec-ch-ua-platform:"Linux"
455 const chUaPlatformRegEx = /sec-ch-ua-platform:"[a-zA-Z]*"/g;
456 output = output.replaceAll(chUaPlatformRegEx, 'sec-ch-ua-platform:"<os>"');
457
458 const savedSnapshot = /Saved snapshot to (.*)/g;
459 output = output.replaceAll(savedSnapshot, 'Saved snapshot to <file>');
460
461 const acceptLanguageRegEx = /accept-language:.*\n/g;
462 output = output.replaceAll(acceptLanguageRegEx, 'accept-language:<lang>\n');
463
464 // Stabilize URL-encoded file paths
465 const fileUriRegEx = /file%3A%2F%2F%2F[^)\n]+/g;
466 output = output.replaceAll(fileUriRegEx, '<file-path>');
467
468 return output;
469}
470
471export function getMockAggregatedIssue(): sinon.SinonStubbedInstance<DevTools.AggregatedIssue> {
472 const mockAggregatedIssue = sinon.createStubInstance(

Callers 4

stabilizeFunction · 0.85
console.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected