( streamUrl: URL, sessionId: string | undefined, )
| 43 | } |
| 44 | |
| 45 | export function buildHistoricalSessionEventsUrl( |
| 46 | streamUrl: URL, |
| 47 | sessionId: string | undefined, |
| 48 | ): string | null { |
| 49 | if (!sessionId) { |
| 50 | return null |
| 51 | } |
| 52 | if (!/^\/v1\/session_ingress\/ws\/[^/]+$/.test(streamUrl.pathname)) { |
| 53 | return null |
| 54 | } |
| 55 | const eventsUrl = new URL(streamUrl.href) |
| 56 | eventsUrl.protocol = eventsUrl.protocol === 'wss:' ? 'https:' : 'http:' |
| 57 | eventsUrl.pathname = `/v1/sessions/${sessionId}/events` |
| 58 | eventsUrl.search = '' |
| 59 | eventsUrl.hash = '' |
| 60 | return eventsUrl.toString() |
| 61 | } |
| 62 | |
| 63 | function isReplayableHistoricalSessionEvent( |
| 64 | event: unknown, |
no test coverage detected