From fd2a1390b9baa5e1192b297a7a9a3a9d5e57ef59 Mon Sep 17 00:00:00 2001 From: hampus-fluxer Date: Tue, 6 Jan 2026 04:53:05 +0100 Subject: [PATCH] fix(app): respect angle brackets for theme links too (#52) --- fluxer_app/src/utils/CodeLinkUtils.tsx | 2 +- fluxer_app/src/utils/ThemeUtils.tsx | 5 +++++ fluxer_app/src/utils/linkSuppressionUtils.ts | 6 +----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fluxer_app/src/utils/CodeLinkUtils.tsx b/fluxer_app/src/utils/CodeLinkUtils.tsx index c4766776..b4515cd5 100644 --- a/fluxer_app/src/utils/CodeLinkUtils.tsx +++ b/fluxer_app/src/utils/CodeLinkUtils.tsx @@ -17,8 +17,8 @@ * along with Fluxer. If not, see . */ -import * as RegexUtils from '~/utils/RegexUtils'; import {isLinkWrappedInAngleBrackets} from '~/utils/linkSuppressionUtils'; +import * as RegexUtils from '~/utils/RegexUtils'; export interface CodeLinkConfig { shortHost: string; diff --git a/fluxer_app/src/utils/ThemeUtils.tsx b/fluxer_app/src/utils/ThemeUtils.tsx index ca45e022..0b7a4855 100644 --- a/fluxer_app/src/utils/ThemeUtils.tsx +++ b/fluxer_app/src/utils/ThemeUtils.tsx @@ -18,6 +18,7 @@ */ import RuntimeConfigStore from '~/stores/RuntimeConfigStore'; +import {isLinkWrappedInAngleBrackets} from '~/utils/linkSuppressionUtils'; import * as RegexUtils from '~/utils/RegexUtils'; const THEME_ID_REGEX = '[a-zA-Z0-9-]{2,32}'; @@ -63,6 +64,10 @@ const matchThemes = (content: string | null, maxMatches = 1): Array => { let match: RegExpExecArray | null; while ((match = regex.exec(content)) !== null && codes.length < maxMatches) { const code = match[1]; + const matchedText = match[0]; + if (isLinkWrappedInAngleBrackets(content, match.index ?? 0, matchedText.length)) { + continue; + } if (code && !seen.has(code)) { seen.add(code); codes.push(code); diff --git a/fluxer_app/src/utils/linkSuppressionUtils.ts b/fluxer_app/src/utils/linkSuppressionUtils.ts index 70bd2abe..5d8f7f83 100644 --- a/fluxer_app/src/utils/linkSuppressionUtils.ts +++ b/fluxer_app/src/utils/linkSuppressionUtils.ts @@ -17,11 +17,7 @@ * along with Fluxer. If not, see . */ -export function isLinkWrappedInAngleBrackets( - content: string, - matchStart: number, - matchLength: number, -): boolean { +export function isLinkWrappedInAngleBrackets(content: string, matchStart: number, matchLength: number): boolean { if (matchLength <= 0) return false; const beforeIndex = matchStart - 1;