From ca79d824cc3cc257dd4ca1101225d5aaba57a162 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Mon, 18 Mar 2024 17:56:35 +0100 Subject: [PATCH] Allow dashes and undescores in hashtags --- src/components/ParsedNote/ParsedNote.tsx | 4 ++-- src/constants.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ParsedNote/ParsedNote.tsx b/src/components/ParsedNote/ParsedNote.tsx index 0fbf3df..b2f4088 100644 --- a/src/components/ParsedNote/ParsedNote.tsx +++ b/src/components/ParsedNote/ParsedNote.tsx @@ -40,7 +40,7 @@ import { hookForDev } from '../../lib/devTools'; import { getMediaUrl as getMediaUrlDefault } from "../../lib/media"; import NoteImage from '../NoteImage/NoteImage'; import { createStore, unwrap } from 'solid-js/store'; -import { linebreakRegex, shortMentionInWords, shortNoteWords, specialCharsRegex, urlExtractRegex } from '../../constants'; +import { hashtagCharsRegex, linebreakRegex, shortMentionInWords, shortNoteWords, specialCharsRegex, urlExtractRegex } from '../../constants'; import { useIntl } from '@cookbook/solid-intl'; import { actions } from '../../translations'; @@ -991,7 +991,7 @@ const ParsedNote: Component<{ let [_, term] = token.split('#'); let end = ''; - let match = specialCharsRegex.exec(term); + let match = hashtagCharsRegex.exec(term); if (match) { const i = match.index; diff --git a/src/constants.ts b/src/constants.ts index 476a2a6..fe9e057 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -262,6 +262,7 @@ export const profileRegexG = /nostr:((npub|nprofile)1\w+)\b/g; export const editMentionRegex = /(?:\s|^)@\`(.*?)\`/ig; export const specialCharsRegex = /[^A-Za-z0-9]/; +export const hashtagCharsRegex = /[^A-Za-z0-9\-\_]/; // How long, in words, should a short note be export const shortNoteWords = 200;