Activate snort.social NIP-5 service #51

Merged
v0l merged 2 commits from snort-nip5 into main 2023-01-13 17:15:54 +00:00
Showing only changes of commit 6b34372b8d - Show all commits

View File

@ -68,10 +68,17 @@ export default function Nip5Service(props: Nip05ServiceProps) {
}, [props]);
useEffect(() => {
if (handle.length === 0) {
setAvailabilityResponse(undefined);
}
setError(undefined);
setAvailabilityResponse(undefined);
if (handle && domain) {
if(handle.length < (domainConfig?.length[0] ?? 2)) {
setAvailabilityResponse({ available: false, why: "TOO_SHORT" });
return;
}
if(handle.length > (domainConfig?.length[1] ?? 20)) {
setAvailabilityResponse({ available: false, why: "TOO_LONG" });
return;
}
let rx = new RegExp(domainConfig?.regex[0] ?? "", domainConfig?.regex[1] ?? "");
if (!rx.test(handle)) {
setAvailabilityResponse({ available: false, why: "REGEX" });