UNPKG

@dash0/sdk-web

Version:

Dash0's Web SDK to collect telemetry from end-users' web browsers

16 lines (13 loc) 390 B
import { parseUrl } from "./url"; /** Returns the origin if present (if in browser context). */ function getOrigin(): string | undefined { return typeof location !== "undefined" ? location.origin : undefined; } export function isSameOrigin(url: string) { try { const parsedUrl = parseUrl(url); return parsedUrl.origin === getOrigin(); } catch (_e) { return false; } }