Determines whether a URL string refers to a cross-origin resource, using purely static string analysis without any `window` or runtime context. Designed to be SSR-deterministic, avoiding React hydration mismatches caused by server/client value divergence. ## Key Components **`isCrossOriginUrl(url)`** Returns `true` if the URL would resolve to a different origin; `false` for relative paths, fragments, query-only strings, and nullish values. | Input pattern | Result | Reason | |---|---|---| | `null` / `undefined` / `""` | `false` | No URL | | `#anchor`, `?tab=x` | `false` | Same-document reference | | `/path/to/page` | `false` | Relative path, same origin | | `//cdn.example.com/...` | `true` | Protocol-relative, explicit host | | `https://flamingo.run/...` | `true` | Absolute URL, explicit host | | `http://external.com/...` | `true` | Absolute URL, explicit host | ## Usage Example ```typescript import { isCrossOriginUrl } from './is-cross-origin-url' // Navigation link — open externally if cross-origin const href = buildContentURL(item) const openInNewTab = isCrossOriginUrl(href) // isCrossOriginUrl('/support') // false — same-origin relative path isCrossOriginUrl('https://flamingo.run') // true — external absolute URL isCrossOriginUrl('#section') // false — fragment, same page isCrossOriginUrl(null) // false — safe nullish handling ``` ## Notes - Intentionally avoids `window.location` comparisons to stay SSR-safe - Same-platform absolute URLs (e.g. from `buildContentURL`) are expected to be handled upstream via `targetPlatform` checks before this function is reached - Source: [`packages/utils/is-cross-origin-url.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/packages/utils/is-cross-origin-url.ts)