API reference › @evolu/common › local‑first/Owner › parseOwnerIdFromOwnerWebSocketTransportUrl
function parseOwnerIdFromOwnerWebSocketTransportUrl(
url: string,
): (string & Brand<"Id"> & Brand<"OwnerId">) | null;
Defined in: packages/common/src/local-first/Owner.ts:512
Extracts OwnerId from an OwnerWebSocketTransport URL query string.
Parses the query string ?ownerId=... and validates that the extracted value
is a valid OwnerId.
Example
import {
assertEqual,
parseOwnerIdFromOwnerWebSocketTransportUrl,
testAppOwner,
} from "@evolu/common";
const url = `/sync?ownerId=${testAppOwner.id}`;
assertEqual(parseOwnerIdFromOwnerWebSocketTransportUrl(url), testAppOwner.id);
assertEqual(
parseOwnerIdFromOwnerWebSocketTransportUrl("/sync?ownerId=invalid"),
null,
);