(interceptorOptions: unknown)
| 65 | } |
| 66 | |
| 67 | function extractRequestContext(interceptorOptions: unknown): RequestContext { |
| 68 | if (!isRecord(interceptorOptions)) { |
| 69 | return {}; |
| 70 | } |
| 71 | |
| 72 | const prefix = |
| 73 | typeof interceptorOptions.prefix === "string" ? interceptorOptions.prefix : undefined; |
| 74 | const request = isRecord(interceptorOptions.request) ? interceptorOptions.request : undefined; |
| 75 | |
| 76 | const method = request && typeof request.method === "string" ? request.method : undefined; |
| 77 | |
| 78 | const urlRaw = request ? request.url : undefined; |
| 79 | const url = |
| 80 | urlRaw instanceof URL ? urlRaw.toString() : typeof urlRaw === "string" ? urlRaw : undefined; |
| 81 | |
| 82 | const path = urlRaw instanceof URL ? `${urlRaw.pathname}${urlRaw.search}` : undefined; |
| 83 | |
| 84 | const headers = request ? redactHeaders(request.headers) : undefined; |
| 85 | |
| 86 | return { |
| 87 | method, |
| 88 | url, |
| 89 | path, |
| 90 | prefix, |
| 91 | headers, |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | interface JsonSafeOptions { |
| 96 | depth: number; |
no test coverage detected