From e3613578f97c6c281f3bf91cc4f64299c92a38c7 Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Mon, 18 Nov 2024 16:25:46 -0500 Subject: [PATCH] Add links for files from Community Contracts --- packages/ui/src/utils/inject-hyperlinks.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/utils/inject-hyperlinks.ts b/packages/ui/src/utils/inject-hyperlinks.ts index 4bec80bd..77efa300 100644 --- a/packages/ui/src/utils/inject-hyperlinks.ts +++ b/packages/ui/src/utils/inject-hyperlinks.ts @@ -2,7 +2,10 @@ import { version as contractsVersion } from "@openzeppelin/contracts/package.jso export function injectHyperlinks(code: string) { // We are modifying HTML, so use HTML escaped chars. The pattern excludes paths that include /../ in the URL. - const importRegex = /"(@openzeppelin\/)(contracts-upgradeable\/|contracts\/)((?:(?!\.\.)[^/]+\/)*?[^/]*?)"/g + const contractsRegex = /"(@openzeppelin\/)(contracts-upgradeable\/|contracts\/)((?:(?!\.\.)[^/]+\/)*?[^/]*?)"/g + const communityContractsRegex = /"(@openzeppelin\/)(community-contracts\/contracts\/)((?:(?!\.\.)[^/]+\/)*?[^/]*?)"/g - return code.replace(importRegex, `"$1$2$3"`); + return code. + replace(contractsRegex, `"$1$2$3"`). + replace(communityContractsRegex, `"$1$2$3"`); }