feat: update hashtag regex

This commit is contained in:
codytseng
2024-11-09 22:55:18 +08:00
parent 062e36330c
commit 524c57c237
2 changed files with 2 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import { EmbeddedHashtag } from '../components/Embedded'
import { TEmbeddedRenderer } from './types'
export const embeddedHashtagRenderer: TEmbeddedRenderer = {
regex: /#([^\s#]+)/g,
regex: /#([\p{L}\p{N}\p{M}]+)/gu,
render: (hashtag: string, index: number) => {
return <EmbeddedHashtag key={`hashtag-${index}-${hashtag}`} hashtag={hashtag} />
}

View File

@@ -107,7 +107,7 @@ export async function extractMentions(content: string, parentEvent?: Event) {
export function extractHashtags(content: string) {
const hashtags: string[] = []
const matches = content.match(/#([^\s#]+)/g)
const matches = content.match(/#[\p{L}\p{N}\p{M}]+/gu)
matches?.forEach((m) => {
const hashtag = m.slice(1).toLowerCase()
if (hashtag) {