URL Input

Catches broken, insecure and disguised links: missing https, lookalike hostnames, user@host tricks, typo'd endings and tracking clutter.

StopsLookalike or broken link saved

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/url-input.json

The files land in your project. They're yours to edit.

Usage

url-input-usage.tsx
import { analyzeUrl, UrlInput } from "@/components/ui/url-input"

<UrlInput label="Link to share" defaultValue={shared} onUrlChange={setSaved} />

What it catches

  • Missing scheme, with https:// added
  • http links, with a switch to https
  • Lookalike (homoglyph) hostnames, shown decoded from xn-- punycode
  • A user@host prefix that disguises the real site
  • Typo'd top-level domains (.con, .cmo)
  • Tracking parameters (utm_*, fbclid…), stripped in one tap

Props

UrlInput props
PropTypeDefault
label

Visible label.

string"Website"
hint

Helper text shown under the field while there is nothing to warn about.

string—
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the raw text on every change, including one-tap fixes.

(value: string) => void—
onUrlChange

Called with the normalized absolute URL, or `null` while the text isn't a usable address.

(url: string | null) => void—
trackingParams

Parameter names treated as tracking; `utm_*` style prefixes are supported.

string[]DEFAULT_TRACKING_PARAMS
removeTrackingLabel

Label of the fix that strips tracking parameters.

string"Remove tracking"
useHttpsLabel

Label of the fix that upgrades http:// to https://.

string"Use https"
messages

Override any other visible string.

Partial<typeof URL_INPUT_MESSAGES>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label>; aria-invalid and hints via aria-describedby
  • Hints and fixes in a polite live region
  • Fix buttons have text labels

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Validate and normalise URLs server-side, and check them against allowlists or safe-browsing services where it matters.

  • Does not fetch the URL or check that it resolves or is safe
  • Lookalike detection covers common Cyrillic/Greek confusables
  • The tracking list is a starter set you can extend

What it stops

Lookalike or broken link saved

Also known as

url · link · website field · https · utm strip · homograph · link input · profile link

Field type

Dependencies

Pairs well with