1
mirror of https://github.com/jakejarvis/hoot.git synced 2025-10-18 20:14:25 -04:00

Add non-public TLD handling to DomainUnregisteredState component

This commit is contained in:
2025-10-12 14:55:46 -04:00
parent 7a4722816d
commit d8604824de
4 changed files with 58 additions and 28 deletions

View File

@@ -1,5 +1,3 @@
import type React from "react";
interface IconProps {
className?: string;
}

View File

@@ -1,5 +1,6 @@
import { ShoppingCart } from "lucide-react";
import { Button } from "@/components/ui/button";
import { NONPUBLIC_TLDS } from "@/lib/constants";
interface DomainUnregisteredStateProps {
domain: string;
@@ -8,6 +9,10 @@ interface DomainUnregisteredStateProps {
export function DomainUnregisteredState({
domain,
}: DomainUnregisteredStateProps) {
const lower = (domain ?? "").toLowerCase();
const isNonPublicTld = NONPUBLIC_TLDS.some((suffix) =>
lower.endsWith(suffix),
);
return (
<div
className="relative overflow-hidden rounded-3xl border border-black/10 bg-background/60 p-8 text-center shadow-2xl shadow-black/10 backdrop-blur-xl supports-[backdrop-filter]:bg-background/60 dark:border-white/10"
@@ -23,31 +28,35 @@ export function DomainUnregisteredState({
<p className="mt-2 text-muted-foreground text-sm sm:text-base">
appears to be unregistered.
</p>
<div className="mt-5 flex justify-center">
<Button size="lg" variant="outline" asChild>
<a
href={`https://porkbun.com/checkout/search?q=${domain}`}
target="_blank"
rel="noopener"
aria-label="Register this domain"
>
<ShoppingCart />
Until now?
</a>
</Button>
</div>
<p className="mt-6 text-muted-foreground text-xs">
This is not an affiliate link, but it{" "}
<a
href="https://jarv.is/contact"
target="_blank"
rel="noopener"
className="text-foreground/85 underline underline-offset-2 hover:text-foreground/60"
>
might be
</a>{" "}
in the future.
</p>
{!isNonPublicTld && (
<>
<div className="mt-5 flex justify-center">
<Button size="lg" variant="outline" asChild>
<a
href={`https://porkbun.com/checkout/search?q=${domain}`}
target="_blank"
rel="noopener"
aria-label="Register this domain"
>
<ShoppingCart />
Until now?
</a>
</Button>
</div>
<p className="mt-6 text-muted-foreground text-xs">
This is not an affiliate link, but it{" "}
<a
href="https://jarv.is/contact"
target="_blank"
rel="noopener"
className="text-foreground/85 underline underline-offset-2 hover:text-foreground/60"
>
might be
</a>{" "}
in the future.
</p>
</>
)}
</div>
);
}

View File

@@ -1,6 +1,5 @@
"use client";
import type * as React from "react";
import { createContext, useContext, useMemo } from "react";
import {
Popover as UiPopover,

View File

@@ -19,4 +19,28 @@ export const BLACKLISTED_SUFFIXES: readonly string[] = [
".ts.map",
".mjs.map",
".cjs.map",
// other
".arpa",
];
// TLDs or domain suffixes that are not generally available to the public.
// This is a small, non-exhaustive list that can be expanded over time.
// Values should be lowercase and include the leading dot for suffix matching.
export const NONPUBLIC_TLDS: readonly string[] = [
".edu", // US accredited post-secondary institutions
".gov", // US government
".mil", // US military
".int", // International treaty-based orgs
".gov.uk", // UK government
".ac.uk", // UK academia
".aero",
".coop",
".museum",
".jobs",
".travel",
".post",
".tel",
// TODO: add brands (.google, .amazon, etc.)
];