Skip to content

Commit

Permalink
[SWM-363] Fix : encode keyword in search API
Browse files Browse the repository at this point in the history
  • Loading branch information
oikkoikk committed Oct 26, 2023
1 parent bce3f40 commit 044b327
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,22 @@ export default function SearchResults({ searchParams }: Props) {
]) as LectureRecommendations;

const requestParam: SearchLectureParams = {
keyword: searchParams.keyword ?? '',
keyword: decodeURIComponent(searchParams.keyword ?? ''),
limit: searchParams.limit ? Number(searchParams.limit) : LIMIT_PER_FETCH,
next_page_token: '',
filter: searchParams.filter ? searchParams.filter : 'all'
};

const decodedKeyword = decodeURIComponent(requestParam.keyword);

useLayoutEffect(() => {
window.scrollTo({ top: 0 });
}, []);

return (
<>
<title>{getPageTitle(`'${decodedKeyword}' 검색 결과`)}</title>
<title>{getPageTitle(`'${requestParam.keyword}' 검색 결과`)}</title>
<div className='py-20 bg-sroom-gray-200'>
<section className='max-w-screen-xl px-4 mx-auto lg:px-24'>
<SearchResultsHeading keyword={decodedKeyword} />
<SearchResultsHeading keyword={requestParam.keyword} />
<Suspense
fallback={
<SearchResultsSkeleton
Expand Down
1 change: 1 addition & 0 deletions src/components/search/SearchResultsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default async function SearchResultsList({
const fetchSearchResults = async ({ pageParam: next_page_token = '' }) => {
const params: SearchLectureParams = {
...requestParam,
keyword: encodeURIComponent(requestParam.keyword),
next_page_token,
filter
};
Expand Down

0 comments on commit 044b327

Please sign in to comment.