UNPKG

@dash0/sdk-web

Version:

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

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