(text: unknown)
| 432 | } |
| 433 | |
| 434 | export 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 | |
| 471 | export function getMockAggregatedIssue(): sinon.SinonStubbedInstance<DevTools.AggregatedIssue> { |
| 472 | const mockAggregatedIssue = sinon.createStubInstance( |
no outgoing calls
no test coverage detected