diff --git a/src/components/common/DynamicDate.tsx b/src/components/common/DynamicDate.tsx index 942580b..f519258 100644 --- a/src/components/common/DynamicDate.tsx +++ b/src/components/common/DynamicDate.tsx @@ -1,6 +1,6 @@ import type { FunctionComponent } from "react"; import { useBoolean } from "usehooks-ts"; -import { format, formatDistanceToNow } from "date-fns"; +import { format } from "date-fns"; import TimeAgo from "react-timeago"; type DynamicDateProps = { diff --git a/src/env/client.mjs b/src/env/client.mjs index 107c6d3..76c967c 100644 --- a/src/env/client.mjs +++ b/src/env/client.mjs @@ -10,7 +10,7 @@ export const formatErrors = ( Object.entries(errors) .map(([name, value]) => { if (value && "_errors" in value) - return `${name}: ${value._errors.join(", ")}\n`; + return `${String(name)}: ${value._errors.join(", ")}\n`; }) .filter(Boolean); diff --git a/src/hooks/useLookup.tsx b/src/hooks/useLookup.tsx index 9499013..4895f36 100644 --- a/src/hooks/useLookup.tsx +++ b/src/hooks/useLookup.tsx @@ -143,7 +143,7 @@ const useLookup = (warningHandler?: WarningHandler) => { }; preload().catch(console.error); - }, [target]); + }, [target, uriType, warningHandler]); async function getAndParse( url: string, @@ -181,7 +181,7 @@ const useLookup = (warningHandler?: WarningHandler) => { ); } - async function submitInternal(): Promise> { + async function submitInternal(target: string): Promise> { if (target == null || target.length == 0) return Result.err( new Error("A target must be given in order to execute a lookup.") @@ -219,6 +219,7 @@ const useLookup = (warningHandler?: WarningHandler) => { await loadBootstrap("domain"); const url = getRegistryURL(targetType.value, target); + // HTTP if (url.startsWith("http://") && url != repeatableRef.current) { repeatableRef.current = url; return Result.err( @@ -261,7 +262,9 @@ const useLookup = (warningHandler?: WarningHandler) => { target, }: SubmitProps): Promise> { try { - const response = await submitInternal(); + // target is already set in state, but it's also provided by the form callback, so we'll use it. + const response = await submitInternal(target); + if (response.isErr) { setError(response.error.message); console.error(response.error); diff --git a/src/rdap.ts b/src/rdap.ts index 48167c1..1c08bfc 100644 --- a/src/rdap.ts +++ b/src/rdap.ts @@ -42,11 +42,11 @@ export function ipMatch(prefix: string, ip: string) { */ // return the first HTTPS url, or the first URL -export function getBestURL(urls: string[]): string { +export function getBestURL(urls: [string, ...string[]]): string { urls.forEach((url) => { if (url.startsWith("https://")) return url; }); - return urls[0]!; + return urls[0]; } // given a URL, injects that URL into the query input,