From 2ce03420d69839eb7b8d67af45f0550863c26d8e Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 17 Aug 2023 12:49:52 +0200 Subject: [PATCH] [Glitch] Fix case-insensitive comparison of hashtags to do case-folding Port 3ed2bf92d06a5ebaf3ad92a55d5ae3c0c2640686 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/components/hashtag_bar.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.jsx b/app/javascript/flavours/glitch/components/hashtag_bar.jsx index 3ad6362551..3c7e24228d 100644 --- a/app/javascript/flavours/glitch/components/hashtag_bar.jsx +++ b/app/javascript/flavours/glitch/components/hashtag_bar.jsx @@ -15,11 +15,11 @@ const VISIBLE_HASHTAGS = 7; export const HashtagBar = ({ hashtags, text }) => { const renderedHashtags = useMemo(() => { const body = domParser.parseFromString(text, 'text/html').documentElement; - return [].filter.call(body.querySelectorAll('a[href]'), link => link.textContent[0] === '#' || (link.previousSibling?.textContent?.[link.previousSibling.textContent.length - 1] === '#')).map(node => node.textContent.toLowerCase()); + return [].filter.call(body.querySelectorAll('a[href]'), link => link.textContent[0] === '#' || (link.previousSibling?.textContent?.[link.previousSibling.textContent.length - 1] === '#')).map(node => node.textContent); }, [text]); const invisibleHashtags = useMemo(() => ( - hashtags.filter(hashtag => !renderedHashtags.some(textContent => textContent === `#${hashtag.get('name').toLowerCase()}` || textContent === hashtag.get('name').toLowerCase())) + hashtags.filter(hashtag => !renderedHashtags.some(textContent => textContent.localeCompare(`#${hashtag.get('name')}`, undefined, { sensitivity: 'accent' }) === 0 || textContent.localeCompare(hashtag.get('name'), undefined, { sensitivity: 'accent' }) === 0)) ), [hashtags, renderedHashtags]); const [expanded, setExpanded] = useState(false); @@ -47,4 +47,4 @@ export const HashtagBar = ({ hashtags, text }) => { HashtagBar.propTypes = { hashtags: ImmutablePropTypes.list, text: PropTypes.string, -}; \ No newline at end of file +};