Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search page crash when search term contains slash #894

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading