(req: http.IncomingMessage)
| 1261 | } |
| 1262 | |
| 1263 | export function getTestId(req: http.IncomingMessage): string { |
| 1264 | const headerValue = req.headers["x-test-id"]; |
| 1265 | if (Array.isArray(headerValue)) { |
| 1266 | if (headerValue.length > 0 && headerValue[0]) return headerValue[0]; |
| 1267 | } else if (typeof headerValue === "string" && headerValue) { |
| 1268 | return headerValue; |
| 1269 | } |
| 1270 | |
| 1271 | const url = req.url ?? "/"; |
| 1272 | const qIdx = url.indexOf("?"); |
| 1273 | if (qIdx !== -1) { |
| 1274 | const params = new URLSearchParams(url.slice(qIdx + 1)); |
| 1275 | const queryValue = params.get("testId"); |
| 1276 | if (queryValue) return queryValue; |
| 1277 | } |
| 1278 | |
| 1279 | return DEFAULT_TEST_ID; |
| 1280 | } |
| 1281 | |
| 1282 | export function getContext(req: http.IncomingMessage): string | undefined { |
| 1283 | const headerValue = req.headers["x-aimock-context"]; |
no test coverage detected
searching dependent graphs…