Skip to content

Commit

Permalink
Fix search page crash when search term contains slash
Browse files Browse the repository at this point in the history
  • Loading branch information
peolic committed Jan 7, 2025
1 parent a9163b5 commit 33078f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/searchField/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const SearchField: FC<SearchFieldProps> = ({

const handleChange = (result: OnChangeValue<SearchResult, false>) => {
if (result?.type === "ALL")
return navigate(createHref(ROUTE_SEARCH, { term: searchTerm.current }));
return navigate(createHref(ROUTE_SEARCH, { "*": searchTerm.current }));

if (result?.value) {
if (valueIsPerformer(result.value)) onClickPerformer?.(result.value);
Expand All @@ -225,7 +225,7 @@ const SearchField: FC<SearchFieldProps> = ({

const handleKeyDown = (e: KeyboardEvent<HTMLElement>) => {
if (e.key === "Enter" && searchTerm.current && showAllLink) {
navigate(createHref(ROUTE_SEARCH, { term: searchTerm.current }));
navigate(createHref(ROUTE_SEARCH, { "*": searchTerm.current }));
selectRef?.current?.blur();
}
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/constants/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const ROUTE_FORGOT_PASSWORD = "/forgot-password";
export const ROUTE_RESET_PASSWORD = "/reset-password";
export const ROUTE_CONFIRM_EMAIL = "/users/confirm-email";
export const ROUTE_CHANGE_EMAIL = "/users/change-email";
export const ROUTE_SEARCH = "/search/:term";
export const ROUTE_SEARCH = "/search/*";
export const ROUTE_SEARCH_INDEX = "/search/";
export const ROUTE_VERSION = "/version";
export const ROUTE_SITE = "/sites/:id";
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const SceneCard: FC<{ scene: Scene }> = ({ scene }) => (
);

const Search: FC = () => {
const { term } = useParams();
const { "*": term } = useParams();
const navigate = useNavigate();
const { loading, data } = useSearchAll(
{
Expand All @@ -143,7 +143,7 @@ const Search: FC = () => {
(searchTerm: string) =>
navigate(
searchTerm
? createHref(ROUTE_SEARCH, { term: searchTerm })
? createHref(ROUTE_SEARCH, { "*": searchTerm })
: ROUTE_SEARCH_INDEX,
{ replace: true },
),
Expand Down

0 comments on commit 33078f8

Please sign in to comment.