(redirectUri?: string)
| 244 | * Returns defaults if the URI can't be parsed. |
| 245 | */ |
| 246 | export function parseRedirectUri(redirectUri?: string): { port: number; path: string } { |
| 247 | if (!redirectUri) { |
| 248 | return { port: OAUTH_CALLBACK_PORT, path: OAUTH_CALLBACK_PATH } |
| 249 | } |
| 250 | |
| 251 | try { |
| 252 | const url = new URL(redirectUri) |
| 253 | const port = url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80 |
| 254 | const path = url.pathname || OAUTH_CALLBACK_PATH |
| 255 | return { port, path } |
| 256 | } catch { |
| 257 | return { port: OAUTH_CALLBACK_PORT, path: OAUTH_CALLBACK_PATH } |
| 258 | } |
| 259 | } |
no outgoing calls
no test coverage detected