True for /api/chat/[identifier] and any deeper subroute.
(pathname: string)
| 27 | |
| 28 | /** True for /api/chat/[identifier] and any deeper subroute. */ |
| 29 | function isEmbedPath(pathname: string): boolean { |
| 30 | const segments = pathname.split('/') |
| 31 | if (segments.length < 4) return false |
| 32 | if (segments[1] !== 'api') return false |
| 33 | if (segments[2] !== 'chat') return false |
| 34 | const identifier = segments[3] |
| 35 | if (!identifier || EMBED_RESERVED_SEGMENTS.has(identifier)) return false |
| 36 | return true |
| 37 | } |
| 38 | |
| 39 | interface CorsRule { |
| 40 | match: (pathname: string) => boolean |