diff --git a/frontend/src/test/messageParser.test.ts b/frontend/src/test/messageParser.test.ts index 2b67329..beddc36 100644 --- a/frontend/src/test/messageParser.test.ts +++ b/frontend/src/test/messageParser.test.ts @@ -9,7 +9,7 @@ import { describe, it, expect } from 'vitest'; import { findLinkedChannelReferences, formatTime, - isValidLinkedChannelName, + HASHTAG_CHANNEL_NAME_PATTERN, parseSenderFromText, } from '../utils/messageParser'; @@ -103,16 +103,16 @@ describe('formatTime', () => { describe('linked channel references', () => { it('accepts lowercase alphanumeric names with single dashes', () => { - expect(isValidLinkedChannelName('ops')).toBe(true); - expect(isValidLinkedChannelName('ops-1')).toBe(true); - expect(isValidLinkedChannelName('1-2-3')).toBe(true); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('ops')).toBe(true); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('ops-1')).toBe(true); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('1-2-3')).toBe(true); }); it('rejects uppercase, leading or trailing dashes, and repeated dashes', () => { - expect(isValidLinkedChannelName('Ops')).toBe(false); - expect(isValidLinkedChannelName('-ops')).toBe(false); - expect(isValidLinkedChannelName('ops-')).toBe(false); - expect(isValidLinkedChannelName('ops--room')).toBe(false); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('Ops')).toBe(false); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('-ops')).toBe(false); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('ops-')).toBe(false); + expect(HASHTAG_CHANNEL_NAME_PATTERN.test('ops--room')).toBe(false); }); it('finds standalone linked channel references in message text', () => { diff --git a/frontend/src/utils/messageParser.ts b/frontend/src/utils/messageParser.ts index 3d57684..f41ebdb 100644 --- a/frontend/src/utils/messageParser.ts +++ b/frontend/src/utils/messageParser.ts @@ -2,7 +2,7 @@ * Parse sender from channel message text. * Channel messages have format "sender: message". */ -const HASHTAG_CHANNEL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; +export const HASHTAG_CHANNEL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; const HASHTAG_CHANNEL_REFERENCE_PATTERN = /(^|\s)(#[a-z0-9]+(?:-[a-z0-9]+)*)(?=$|[\s.,;:])/g; export function parseSenderFromText(text: string): { sender: string | null; content: string } { @@ -26,9 +26,6 @@ export interface HashtagChannelReference { end: number; } -export function isValidLinkedChannelName(name: string): boolean { - return HASHTAG_CHANNEL_NAME_PATTERN.test(name); -} export function findLinkedChannelReferences(text: string): HashtagChannelReference[] { const references: HashtagChannelReference[] = [];