Skip to content

Commit

Permalink
feat: ignore invalid url in FP
Browse files Browse the repository at this point in the history
  • Loading branch information
totraev committed Sep 12, 2024
1 parent a8f3a3f commit 6d75900
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/api/getFinalityProviders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { encode } from "url-safe-base64";

import { isValidUrl } from "@/utils/url";

import { Pagination } from "../types/api";
import { FinalityProvider } from "../types/finalityProviders";

Expand Down Expand Up @@ -62,7 +64,9 @@ export const getFinalityProviders = async (
description: {
moniker: fp.description.moniker,
identity: fp.description.identity,
website: fp.description.website,
website: isValidUrl(fp.description.website)
? fp.description.website
: "",
securityContact: fp.description.security_contact,
details: fp.description.details,
},
Expand Down
5 changes: 5 additions & 0 deletions src/utils/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const URL_REGEX = /^https?:\/\//;

export function isValidUrl(url: string) {
return URL_REGEX.test(url);
}

0 comments on commit 6d75900

Please sign in to comment.