Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
import { parseBuilderUrl } from "@webstudio-is/protocol";
export const getRequestOrigin = (urlStr: string) => {
const url = new URL(urlStr);
return url.origin;
};
export const isCanvas = (urlStr: string): boolean => {
const url = new URL(urlStr);
const projectId = url.searchParams.get("projectId");
return projectId !== null;
};
export const isBuilderUrl = (urlStr: string): boolean => {
const { projectId } = parseBuilderUrl(urlStr);
return projectId !== undefined;
};
export const getAuthorizationServerOrigin = (urlStr: string): string => {
const origin = getRequestOrigin(urlStr);
const { sourceOrigin } = parseBuilderUrl(origin);
return sourceOrigin;
};