Support broader fedi tag type

This commit is contained in:
xmflsct 2023-01-07 16:41:14 +01:00
parent 50332773c3
commit 44f8900902
1 changed files with 6 additions and 2 deletions

View File

@ -119,7 +119,11 @@ const ParseHTML: React.FC<Props> = ({
const href = node.attribs.href
if (classes) {
if (classes.includes('hashtag')) {
const tag = href.match(new RegExp(/\/tags?\/(.*)/, 'i'))?.[1].toLowerCase()
const children = node.children.map(unwrapNode).join('')
const tag =
href.match(new RegExp(/\/tags?\/(.*)/, 'i'))?.[1]?.toLowerCase() ||
children.match(new RegExp(/#(\S+)/))?.[1]?.toLowerCase()
const paramsHashtag = (params as { hashtag: Mastodon.Tag['name'] } | undefined)
?.hashtag
const sameHashtag = paramsHashtag === tag
@ -143,7 +147,7 @@ const ParseHTML: React.FC<Props> = ({
!sameHashtag &&
navigation.push('Tab-Shared-Hashtag', { hashtag: tag })
}
children={node.children.map(unwrapNode).join('')}
children={children}
/>
)
}