diff --git a/src/screens/Settings/components/ChangeHandleDialog.tsx b/src/screens/Settings/components/ChangeHandleDialog.tsx
index 59e0042526..8e25f89e20 100644
--- a/src/screens/Settings/components/ChangeHandleDialog.tsx
+++ b/src/screens/Settings/components/ChangeHandleDialog.tsx
@@ -293,12 +293,19 @@ function ProvidedHandlePage({
)
}
+// simple domain regex - just catching chars that can't be part of a domain, like @
+// doesn't validate it's *actually* valid, as they might not be finished typing
+// however, does catch leading hypens/dots as well as consecutive dots -sfn
+const SIMPLE_DOMAIN_REGEX =
+ /^(?![.-])(?!.*\.\.)(?!.*[^a-zA-Z0-9.-])[a-zA-Z0-9.-]*-?$/
+
function OwnHandlePage({goToServiceHandle}: {goToServiceHandle: () => void}) {
const {_} = useLingui()
const t = useTheme()
const {currentAccount} = useSession()
const [dnsPanel, setDNSPanel] = useState(true)
const [domain, setDomain] = useState('')
+ const trimmedDomain = domain.trim()
const agent = useAgent()
const control = Dialog.useDialogContext()
const fetchDid = useFetchDid()
@@ -337,6 +344,8 @@ function OwnHandlePage({goToServiceHandle}: {goToServiceHandle: () => void}) {
},
})
+ const isInvalid = !!trimmedDomain && !SIMPLE_DOMAIN_REGEX.test(trimmedDomain)
+
return (
{isSuccess && (
@@ -369,7 +378,7 @@ function OwnHandlePage({goToServiceHandle}: {goToServiceHandle: () => void}) {
Enter the domain you want to use
-
+
void}) {
a.border,
t.atoms.border_contrast_low,
]}>
- _atproto.{domain}
+ _atproto.{trimmedDomain}
>
) : (
@@ -480,7 +489,7 @@ function OwnHandlePage({goToServiceHandle}: {goToServiceHandle: () => void}) {
t.atoms.border_contrast_low,
]}>
- https://{domain}/.well-known/atproto-did
+ https://{trimmedDomain}/.well-known/atproto-did
@@ -523,7 +532,7 @@ function OwnHandlePage({goToServiceHandle}: {goToServiceHandle: () => void}) {