Skip to content

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.

497 B
Raw Blame
import createDebugRaw from "debug";

const getModuleName = (url: string) => {
  const nameParts = url.split("/").pop()?.split(".") ?? [];
  if (nameParts?.length === 0) {
    return "unknown";
  }

  const knownExtensions = ["ts", "tsx", "js", "jsx"];

  if (knownExtensions.includes(nameParts[nameParts.length - 1])) {
    nameParts.pop();
  }

  return nameParts.join(".");
};

export const createDebug = (namespaceOrUrl: string) =>
  createDebugRaw("ws").extend(getModuleName(namespaceOrUrl));