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

Function stabilizeResponseOutput

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

Source from the content-addressed store, hash-verified

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

Callers 3

network.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected