UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

23 lines (20 loc) 720 B
'use strict'; const PLACEHOLDER_BASE_URL = "https://localhost:9999"; const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/; function generateURL(url, params, hash) { const isAbsolute = ABSOLUTE_URL_REGEX.test(url); const urlObject = new URL(url, isAbsolute ? void 0 : PLACEHOLDER_BASE_URL); if (params !== void 0) { for (const [param, value] of Object.entries(params)) { if (value) { urlObject.searchParams.set(param, String(value)); } } } if (!urlObject.hash && hash !== void 0) { urlObject.hash = `#${hash}`; } return isAbsolute ? urlObject.href : urlObject.href.replace(PLACEHOLDER_BASE_URL, ""); } exports.generateURL = generateURL; //# sourceMappingURL=url.cjs.map