mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-06 03:16:07 -06:00
fix minor linting/type errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import type { FunctionComponent } from "react";
|
import type { FunctionComponent } from "react";
|
||||||
import { useBoolean } from "usehooks-ts";
|
import { useBoolean } from "usehooks-ts";
|
||||||
import { format, formatDistanceToNow } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import TimeAgo from "react-timeago";
|
import TimeAgo from "react-timeago";
|
||||||
|
|
||||||
type DynamicDateProps = {
|
type DynamicDateProps = {
|
||||||
|
|||||||
2
src/env/client.mjs
vendored
2
src/env/client.mjs
vendored
@@ -10,7 +10,7 @@ export const formatErrors = (
|
|||||||
Object.entries(errors)
|
Object.entries(errors)
|
||||||
.map(([name, value]) => {
|
.map(([name, value]) => {
|
||||||
if (value && "_errors" in value)
|
if (value && "_errors" in value)
|
||||||
return `${name}: ${value._errors.join(", ")}\n`;
|
return `${String(name)}: ${value._errors.join(", ")}\n`;
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ const useLookup = (warningHandler?: WarningHandler) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
preload().catch(console.error);
|
preload().catch(console.error);
|
||||||
}, [target]);
|
}, [target, uriType, warningHandler]);
|
||||||
|
|
||||||
async function getAndParse<T>(
|
async function getAndParse<T>(
|
||||||
url: string,
|
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)
|
if (target == null || target.length == 0)
|
||||||
return Result.err(
|
return Result.err(
|
||||||
new Error("A target must be given in order to execute a lookup.")
|
new Error("A target must be given in order to execute a lookup.")
|
||||||
@@ -219,6 +219,7 @@ const useLookup = (warningHandler?: WarningHandler) => {
|
|||||||
await loadBootstrap("domain");
|
await loadBootstrap("domain");
|
||||||
const url = getRegistryURL(targetType.value, target);
|
const url = getRegistryURL(targetType.value, target);
|
||||||
|
|
||||||
|
// HTTP
|
||||||
if (url.startsWith("http://") && url != repeatableRef.current) {
|
if (url.startsWith("http://") && url != repeatableRef.current) {
|
||||||
repeatableRef.current = url;
|
repeatableRef.current = url;
|
||||||
return Result.err(
|
return Result.err(
|
||||||
@@ -261,7 +262,9 @@ const useLookup = (warningHandler?: WarningHandler) => {
|
|||||||
target,
|
target,
|
||||||
}: SubmitProps): Promise<Maybe<ParsedGeneric>> {
|
}: SubmitProps): Promise<Maybe<ParsedGeneric>> {
|
||||||
try {
|
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) {
|
if (response.isErr) {
|
||||||
setError(response.error.message);
|
setError(response.error.message);
|
||||||
console.error(response.error);
|
console.error(response.error);
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ export function ipMatch(prefix: string, ip: string) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// return the first HTTPS url, or the first URL
|
// 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) => {
|
urls.forEach((url) => {
|
||||||
if (url.startsWith("https://")) return url;
|
if (url.startsWith("https://")) return url;
|
||||||
});
|
});
|
||||||
return urls[0]!;
|
return urls[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// given a URL, injects that URL into the query input,
|
// given a URL, injects that URL into the query input,
|
||||||
|
|||||||
Reference in New Issue
Block a user