@dash0/sdk-web
Version:
Dash0's Web SDK to collect telemetry from end-users' web browsers
13 lines (10 loc) • 345 B
text/typescript
import { doc, loc } from "./globals";
/**
* Parses url using URL constructor. Supports URL objects as passthrough input to simplify implementations
* May throw if parsing fails
* @param url
*/
export function parseUrl(url: string | URL): URL {
if (typeof url !== "string") return url;
return new URL(url, doc?.baseURI ?? loc?.href);
}