Skip to content

Commit

Permalink
Merge pull request #895 from near/develop
Browse files Browse the repository at this point in the history
develop -> main
  • Loading branch information
charleslavon authored Dec 25, 2023
2 parents 8095fd7 + d107f81 commit 3aeef22
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/vm/VmInitializer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sanitize } from 'dompurify';
import { isValidAttribute } from 'dompurify';
import { setupKeypom } from '@keypom/selector';
import type { WalletSelector } from '@near-wallet-selector/core';
import { setupWalletSelector } from '@near-wallet-selector/core';
Expand Down Expand Up @@ -38,6 +38,7 @@ import { useVmStore } from '@/stores/vm';
import { recordWalletConnect, reset as resetAnalytics } from '@/utils/analytics';
import { networkId, signInContractId } from '@/utils/config';
import { KEYPOM_OPTIONS } from '@/utils/keypom-options';
import { mapValues } from 'lodash';

export default function VmInitializer() {
const [signedIn, setSignedIn] = useState(false);
Expand Down Expand Up @@ -102,7 +103,14 @@ export default function VmInitializer() {
],
}),
customElements: {
Link: ({ href, to, ...rest }: any) => <Link href={sanitize(href ?? to)} {...rest} />,
Link: ({ to, href, ...rest }: { to: string | object | undefined; href: string | object }) => {
const cleanProps = mapValues({ to, href, ...rest }, (val: any, key: string) => {
if (!['to', 'href'].includes(key)) return val;
return typeof val === 'string' && isValidAttribute('a', 'href', val) ? val : 'about:blank';
});

return <Link {...cleanProps} />;
},
},
features: { enableComponentSrcDataKey: true },
});
Expand Down

2 comments on commit 3aeef22

@vercel
Copy link

@vercel vercel bot commented on 3aeef22 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 3aeef22 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.