From ef734c763ce8dd372c2cc60fa311bef1b5d33fe3 Mon Sep 17 00:00:00 2001 From: isaac Date: Wed, 7 Feb 2024 10:07:06 -0800 Subject: [PATCH 1/3] Fix tag search on web --- .../search-bar/ConnectedSearchBar.jsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx index deefd0b4fda..482b2c3bd73 100644 --- a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx +++ b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx @@ -79,14 +79,22 @@ class ConnectedSearchBar extends Component { onSubmit = (value) => { // Encode everything besides tag searches - if (!value.startsWith('#')) { + const pathname = '/search' + if (value.startsWith('#')) { + // perform tag search + const pathname = `/search` + this.props.history.push({ + hash: value.split('#')[1].replace(/\s+/g, ''), + pathname, + state: {} + }) + } else { value = encodeURIComponent(value) + this.props.history.push({ + pathname: pathname + value, + state: {} + }) } - const pathname = `/search/${value}` - this.props.history.push({ - pathname, - state: {} - }) } onSelect = (value) => { From 3d97d1ae66409ad659aee428846813f34124e9a9 Mon Sep 17 00:00:00 2001 From: isaac Date: Wed, 7 Feb 2024 10:52:48 -0800 Subject: [PATCH 2/3] clean --- packages/web/src/components/search-bar/ConnectedSearchBar.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx index 482b2c3bd73..31271894386 100644 --- a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx +++ b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx @@ -82,7 +82,6 @@ class ConnectedSearchBar extends Component { const pathname = '/search' if (value.startsWith('#')) { // perform tag search - const pathname = `/search` this.props.history.push({ hash: value.split('#')[1].replace(/\s+/g, ''), pathname, @@ -91,7 +90,7 @@ class ConnectedSearchBar extends Component { } else { value = encodeURIComponent(value) this.props.history.push({ - pathname: pathname + value, + pathname: pathname + '/' + value, state: {} }) } From f15380804063c2eedff5cd85576bf9a3a430c069 Mon Sep 17 00:00:00 2001 From: isaac Date: Wed, 7 Feb 2024 10:59:10 -0800 Subject: [PATCH 3/3] keep any whitespace --- packages/web/src/components/search-bar/ConnectedSearchBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx index 31271894386..c726932f8d3 100644 --- a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx +++ b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx @@ -83,7 +83,7 @@ class ConnectedSearchBar extends Component { if (value.startsWith('#')) { // perform tag search this.props.history.push({ - hash: value.split('#')[1].replace(/\s+/g, ''), + hash: value.split('#')[1], pathname, state: {} })