/** Same canonical spelling used by CommunityText::hashtag on the backend. */
export function normalizeCommunityTag(tag: string | null | undefined): string {
  return (tag ?? "").trim().replace(/^#+/, "").normalize("NFC").toLowerCase();
}

export function communityTagHref(tag: string): string {
  const normalized = normalizeCommunityTag(tag);
  return normalized ? `/community?tag=${encodeURIComponent(normalized)}` : "/community";
}
