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: import { HEY_TREASURY } from "@/data/constants";
  
  interface DomainParamConfig {
    name: string;
    value: string;
  }
  
  const DOMAIN_PARAM_MAP: Record<string, DomainParamConfig> = {
    "highlight.xyz": { name: "referrer", value: HEY_TREASURY },
    "zora.co": { name: "referrer", value: HEY_TREASURY }
  };
  
  const injectReferrerToUrl = (url: string): string => {
    let parsed: URL;
  
    try {
      parsed = new URL(url);
    } catch {
      return url;
    }
  
    const [, config] =
      Object.entries(DOMAIN_PARAM_MAP).find(([domain]) =>
        parsed.hostname.endsWith(domain)
      ) || [];
  
    if (!config) {
      return url;
    }
  
    parsed.searchParams.set(config.name, config.value);
    return parsed.toString();
  };
  
  export default injectReferrerToUrl;
  