INNER CODE UNIT · TypeScript
isCanonicalRelayOrigin
stablyai/orca · cloud/apps/relay/src/app.ts:1838
function isCanonicalRelayOrigin(value: string): boolean {
const url = new URL(value)
const loopback = ['127.0.0.1', 'localhost', '::1', '[::1]'].includes(url.hostname)
return (
url.origin === value &&
url.pathname === '/' &&
(url.protocol === 'https:' || (loopback && url.protocol === 'http:'))
)
}
function requestTooLarge(contentLength: string | undefined): boolean {
return Number(contentLength ?? 0) > RELAY_PROTOCOL_LIMITS.maxHttpBodyBytes
}