fix(app): respect angle brackets for theme links too (#52)

This commit is contained in:
hampus-fluxer 2026-01-06 04:53:05 +01:00 committed by GitHub
parent 5f627b5b0b
commit fd2a1390b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View File

@ -17,8 +17,8 @@
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>. * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as RegexUtils from '~/utils/RegexUtils';
import {isLinkWrappedInAngleBrackets} from '~/utils/linkSuppressionUtils'; import {isLinkWrappedInAngleBrackets} from '~/utils/linkSuppressionUtils';
import * as RegexUtils from '~/utils/RegexUtils';
export interface CodeLinkConfig { export interface CodeLinkConfig {
shortHost: string; shortHost: string;

View File

@ -18,6 +18,7 @@
*/ */
import RuntimeConfigStore from '~/stores/RuntimeConfigStore'; import RuntimeConfigStore from '~/stores/RuntimeConfigStore';
import {isLinkWrappedInAngleBrackets} from '~/utils/linkSuppressionUtils';
import * as RegexUtils from '~/utils/RegexUtils'; import * as RegexUtils from '~/utils/RegexUtils';
const THEME_ID_REGEX = '[a-zA-Z0-9-]{2,32}'; const THEME_ID_REGEX = '[a-zA-Z0-9-]{2,32}';
@ -63,6 +64,10 @@ const matchThemes = (content: string | null, maxMatches = 1): Array<string> => {
let match: RegExpExecArray | null; let match: RegExpExecArray | null;
while ((match = regex.exec(content)) !== null && codes.length < maxMatches) { while ((match = regex.exec(content)) !== null && codes.length < maxMatches) {
const code = match[1]; const code = match[1];
const matchedText = match[0];
if (isLinkWrappedInAngleBrackets(content, match.index ?? 0, matchedText.length)) {
continue;
}
if (code && !seen.has(code)) { if (code && !seen.has(code)) {
seen.add(code); seen.add(code);
codes.push(code); codes.push(code);

View File

@ -17,11 +17,7 @@
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>. * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/ */
export function isLinkWrappedInAngleBrackets( export function isLinkWrappedInAngleBrackets(content: string, matchStart: number, matchLength: number): boolean {
content: string,
matchStart: number,
matchLength: number,
): boolean {
if (matchLength <= 0) return false; if (matchLength <= 0) return false;
const beforeIndex = matchStart - 1; const beforeIndex = matchStart - 1;