Skip to content

Commit

Permalink
feat: add https when necessary in validators
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Apr 16, 2024
1 parent 2c4a67e commit 0134827
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/features/staking/components/validator-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
formatVotingPowerPerc,
formatXionToUSD,
} from "../lib/formatters";
import { parseWebsite } from "../lib/utils/misc";
import { DivisorHorizontal, DivisorVertical } from "./divisor";
import StakingModals from "./staking-modals";
import ValidatorDelegation from "./validator-delegation";
Expand Down Expand Up @@ -90,6 +91,8 @@ export default function ValidatorPage() {
stakingRef.staking.state,
);

const validatorWebsite = parseWebsite(validatorDetails.description.website);

return (
<>
<div className="page-container flex w-full flex-col gap-[16px] px-[16px] pb-[32px]">
Expand Down Expand Up @@ -210,14 +213,11 @@ export default function ValidatorPage() {
<ClipboardCopy textToCopy={validatorDetails.operatorAddress} />
</div>
</div>
{validatorDetails.description.website && (
{validatorWebsite && (
<div className="flex flex-col gap-[8px]">
<Heading8 color="text-white">Website</Heading8>
<Link
href={validatorDetails.description.website}
target="_blank"
>
{validatorDetails.description.website}
<Link href={validatorWebsite} target="_blank">
{validatorWebsite}
</Link>
</div>
)}
Expand Down
17 changes: 17 additions & 0 deletions src/features/staking/lib/utils/misc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const urlMapping: Record<string, string | undefined> = {
// "https://www.stakelab.fr": "https://www.stakelab.zone",
};

export const parseWebsite = (website?: string) => {
if (!website?.trim()) return "";

const mappedUrl = urlMapping[website];

if (mappedUrl) return mappedUrl;

if (!website.startsWith("https://")) {
return `https://${website}`;
}

return website;
};

0 comments on commit 0134827

Please sign in to comment.