Skip to content

Commit

Permalink
fix: accept localhost as an acceptable domain name
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Jun 16, 2024
1 parent d32c9b1 commit 61aa383
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 5 additions & 3 deletions dashboard/app/components/index/Add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ interface AddProps {
}

const addWebsiteSchema = z.object({
hostname: z.string().refine((value) => isFQDN(value), {
message: 'Please enter a valid domain name.',
}),
hostname: z
.string()
.refine((value) => value === 'localhost' || isFQDN(value), {
message: 'Please enter a valid domain name.',
}),
});

export const Add = ({ close }: AddProps) => {
Expand Down
9 changes: 1 addition & 8 deletions dashboard/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const clientLoader = async () => {

const { data, res } = await websiteList({ query: { summary: true } });

if (!res.ok) {
if (!res.ok || !data) {
if (res.status === 404) {
return json<LoaderData>({ websites: [] });
}
Expand All @@ -44,12 +44,6 @@ export const clientLoader = async () => {
});
}

if (!data) {
throw json('Failed to fetch websites.', {
status: 500,
});
}

return json<LoaderData>({ websites: data });
};

Expand All @@ -59,7 +53,6 @@ export const clientAction = async ({ request }: ClientActionFunctionArgs) => {
const hostname = body.get('hostname')
? String(body.get('hostname'))
: undefined;
const name = body.get('name') ? String(body.get('name')) : hostname;

if (!hostname) {
throw json('Missing hostname', {
Expand Down

0 comments on commit 61aa383

Please sign in to comment.