mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-06 01:16:00 -06:00
fix minor linting/type errors
This commit is contained in:
@@ -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 = {
|
||||
|
||||
2
src/env/client.mjs
vendored
2
src/env/client.mjs
vendored
@@ -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);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ const useLookup = (warningHandler?: WarningHandler) => {
|
||||
};
|
||||
|
||||
preload().catch(console.error);
|
||||
}, [target]);
|
||||
}, [target, uriType, warningHandler]);
|
||||
|
||||
async function getAndParse<T>(
|
||||
url: string,
|
||||
@@ -181,7 +181,7 @@ const useLookup = (warningHandler?: WarningHandler) => {
|
||||
);
|
||||
}
|
||||
|
||||
async function submitInternal(): Promise<Result<ParsedGeneric, Error>> {
|
||||
async function submitInternal(target: string): Promise<Result<ParsedGeneric, Error>> {
|
||||
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<Maybe<ParsedGeneric>> {
|
||||
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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user