diff --git a/src/util.ts b/src/util.ts index c2f0a77..0ba30e6 100644 --- a/src/util.ts +++ b/src/util.ts @@ -2,6 +2,8 @@ import { GuildMember } from "@lilybird/transformers"; import { BUN_EMOJIS } from "./constants.ts"; import { parse, formatMarkdown } from "bun-tracestrings"; +const URL_REGEX = /\(\s*(https?:\/\/[^\s\[\]]+)\s*\)/gi; + export function safeSlice>( input: T, length: number @@ -63,10 +65,22 @@ export async function getBunReportDetailsInMarkdown( } const json = await res.json(); - console.log(json); - return formatMarkdown({ + let content = formatMarkdown({ ...parsed, ...json, }); + + for (const match of content.matchAll(URL_REGEX)) { + let url = match[1]; + if (url.endsWith(")")) { + url = url.slice(0, -1); + } + + if (!url.startsWith("<")) { + content = content.replace(url, `<${url}>`); + } + } + + return content; }