From 288c3c63c712014ff2d5666230f154d9c8bc4c41 Mon Sep 17 00:00:00 2001 From: Eyejoker Date: Fri, 13 Mar 2026 19:28:17 +0900 Subject: [PATCH] feat: convert non-image markdown links to readable filenames in Discord MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [BuildPanel.tsx](/long/path#L320) → `BuildPanel.tsx:320` Keeps Discord output clean since local paths aren't clickable anyway. --- src/channels/discord.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/channels/discord.ts b/src/channels/discord.ts index 0fb1913..c30eeff 100644 --- a/src/channels/discord.ts +++ b/src/channels/discord.ts @@ -323,9 +323,15 @@ export class DiscordChannel implements Channel { } } let cleaned = text - .replace(MD_LINK_RE, (full, p) => - IMAGE_EXTS.test(p) && seen.has(p.trim()) ? '' : full, - ) + .replace(MD_LINK_RE, (full, p, _offset, _str, groups) => { + const trimmed = p.trim(); + // Image links: remove entirely (attached as files) + if (IMAGE_EXTS.test(trimmed) && seen.has(trimmed)) return ''; + // Non-image local path links: convert to readable filename + const basename = path.basename(trimmed.replace(/#.*$/, '')); + const lineMatch = trimmed.match(/#L(\d+)/); + return lineMatch ? `\`${basename}:${lineMatch[1]}\`` : `\`${basename}\``; + }) .trim(); // Convert @username mentions to Discord mention format