repo_description: Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
repo_topics: blockchain crypto dapp graphql hacktoberfest lens-protocol nextjs react social-media tailwindcss turborepo typescript vitest wagmi web3
code: const truncateUrl = (url: string, maxLength: number): string => {
    try {
      const parsed = new URL(url);
      const stripped =
        `${parsed.host}${parsed.pathname}${parsed.search}${parsed.hash}`.replace(
          /^www\./,
          ""
        );
  
      if (parsed.hostname.endsWith("hey.xyz")) return stripped;
  
      return stripped.length > maxLength
        ? `${stripped.slice(0, maxLength - 1)}…`
        : stripped;
    } catch {
      // fallback: remove protocol/www, truncate if needed
      const stripped = `${url.replace(/^(https?:\/\/)?(www\.)?/, "")}`;
      return stripped.length > maxLength
        ? `${stripped.slice(0, maxLength - 1)}…`
        : stripped;
    }
  };
  
  export default truncateUrl;
  