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

Function stabilizeResponseOutput

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

Source from the content-addressed store, hash-verified

274}
275
276export function stabilizeResponseOutput(text: unknown) {
277 if (typeof text !== 'string') {
278 throw new Error('Input must be string');
279 }
280 let output = text;
281 const dateRegEx = /.{3}, \d{2} .{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z]{3}/g;
282 output = output.replaceAll(dateRegEx, '<long date>');
283
284 const localhostRegEx = /localhost:\d{5}/g;
285 output = output.replaceAll(localhostRegEx, 'localhost:<port>');
286
287 const userAgentRegEx = /user-agent:.*\n/g;
288 output = output.replaceAll(userAgentRegEx, 'user-agent:<user-agent>\n');
289
290 const chUaRegEx = /sec-ch-ua:"Chromium";v="\d{3}"/g;
291 output = output.replaceAll(chUaRegEx, 'sec-ch-ua:"Chromium";v="<version>"');
292
293 // sec-ch-ua-platform:"Linux"
294 const chUaPlatformRegEx = /sec-ch-ua-platform:"[a-zA-Z]*"/g;
295 output = output.replaceAll(chUaPlatformRegEx, 'sec-ch-ua-platform:"<os>"');
296
297 const savedSnapshot = /Saved snapshot to (.*)/g;
298 output = output.replaceAll(savedSnapshot, 'Saved snapshot to <file>');
299
300 const acceptLanguageRegEx = /accept-language:.*\n/g;
301 output = output.replaceAll(acceptLanguageRegEx, 'accept-language:<lang>\n');
302
303 // Stabilize URL-encoded file paths
304 const fileUriRegEx = /file%3A%2F%2F%2F[^)\n]+/g;
305 output = output.replaceAll(fileUriRegEx, '<file-path>');
306
307 return output;
308}
309
310export function getMockAggregatedIssue(): sinon.SinonStubbedInstance<DevTools.AggregatedIssue> {
311 const mockAggregatedIssue = sinon.createStubInstance(

Callers 3

network.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected