(pathPrefix: string | undefined)
| 63 | } |
| 64 | |
| 65 | const normalizePathPrefix = (pathPrefix: string | undefined): string => { |
| 66 | if (typeof pathPrefix !== 'string') { |
| 67 | return '' |
| 68 | } |
| 69 | |
| 70 | const prefix = pathPrefix.split(',')[0].trim() |
| 71 | |
| 72 | if (!prefix.startsWith('/') || prefix.startsWith('//')) { |
| 73 | return '' |
| 74 | } |
| 75 | |
| 76 | try { |
| 77 | const { pathname } = new URL(prefix, 'http://nostream.local') |
| 78 | const normalized = pathname.replace(/\/+$/, '') |
| 79 | |
| 80 | return normalized === '/' ? '' : normalized |
| 81 | } catch { |
| 82 | return '' |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | const getRelayUrlPathPrefix = (relayUrl: string | undefined): string => { |
| 87 | if (typeof relayUrl !== 'string') { |
no outgoing calls
no test coverage detected