diff --git a/src/app/api/getFinalityProviders.ts b/src/app/api/getFinalityProviders.ts index 59941156..6d444d4e 100644 --- a/src/app/api/getFinalityProviders.ts +++ b/src/app/api/getFinalityProviders.ts @@ -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"; @@ -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, }, diff --git a/src/utils/url.ts b/src/utils/url.ts new file mode 100644 index 00000000..6bbc577a --- /dev/null +++ b/src/utils/url.ts @@ -0,0 +1,5 @@ +const URL_REGEX = /^https?:\/\//; + +export function isValidUrl(url: string) { + return URL_REGEX.test(url); +}