From 1cf49517b517e8bee90bf937d033dff35cc9f690 Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 7 Mar 2024 09:04:02 -0800 Subject: [PATCH] Allow all encoding for hashtags in URL (#3131) --- src/components/TagMenu/index.tsx | 4 ++-- src/components/TagMenu/index.web.tsx | 4 ++-- src/screens/Hashtag.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/TagMenu/index.tsx b/src/components/TagMenu/index.tsx index c9ced9a5..849a3f42 100644 --- a/src/components/TagMenu/index.tsx +++ b/src/components/TagMenu/index.tsx @@ -98,7 +98,7 @@ export function TagMenu({ control.close(() => { navigation.push('Hashtag', { - tag: tag.replaceAll('#', '%23'), + tag: encodeURIComponent(tag), }) }) @@ -153,7 +153,7 @@ export function TagMenu({ control.close(() => { navigation.push('Hashtag', { - tag: tag.replaceAll('#', '%23'), + tag: encodeURIComponent(tag), author: authorHandle, }) }) diff --git a/src/components/TagMenu/index.web.tsx b/src/components/TagMenu/index.web.tsx index a0dc2bce..8245bd01 100644 --- a/src/components/TagMenu/index.web.tsx +++ b/src/components/TagMenu/index.web.tsx @@ -66,7 +66,7 @@ export function TagMenu({ label: _(msg`See ${truncatedTag} posts`), onPress() { navigation.push('Hashtag', { - tag: tag.replaceAll('#', '%23'), + tag: encodeURIComponent(tag), }) }, testID: 'tagMenuSearch', @@ -83,7 +83,7 @@ export function TagMenu({ label: _(msg`See ${truncatedTag} posts by user`), onPress() { navigation.push('Hashtag', { - tag: tag.replaceAll('#', '%23'), + tag: encodeURIComponent(tag), author: authorHandle, }) }, diff --git a/src/screens/Hashtag.tsx b/src/screens/Hashtag.tsx index f1b81737..776cc585 100644 --- a/src/screens/Hashtag.tsx +++ b/src/screens/Hashtag.tsx @@ -42,7 +42,7 @@ export default function HashtagScreen({ const [isPTR, setIsPTR] = React.useState(false) const fullTag = React.useMemo(() => { - return `#${tag.replaceAll('%23', '#')}` + return `#${decodeURIComponent(tag)}` }, [tag]) const queryParam = React.useMemo(() => { @@ -83,7 +83,7 @@ export default function HashtagScreen({ const onShare = React.useCallback(() => { const url = new URL('https://bsky.app') - url.pathname = `/hashtag/${tag}` + url.pathname = `/hashtag/${decodeURIComponent(tag)}` if (author) { url.searchParams.set('author', author) }