diff --git a/src/common/utility.js b/src/common/utility.js index f27942c8c4d..36e8807543d 100644 --- a/src/common/utility.js +++ b/src/common/utility.js @@ -345,7 +345,6 @@ export const slugify = (text) => .toLowerCase() .trim() // Remove whitespace from both sides of a string .replace(/\s+/g, '-') // Replace spaces with - - .replace(/[^\w-]+/g, '') // Remove all non-word chars .replace(/--+/g, '-') // Replace multiple - with single - export const unslugify = (slug) => { diff --git a/src/pages/academy/components/_search-banner.tsx b/src/pages/academy/components/_search-banner.tsx index 62a2bd728fa..c510f8588cc 100644 --- a/src/pages/academy/components/_search-banner.tsx +++ b/src/pages/academy/components/_search-banner.tsx @@ -749,12 +749,12 @@ const SearchBanner = ({ hidden }: SearchBannerProps) => { const handleHref = (category) => { if (isBrowser() && window.location.pathname.includes('/academy/videos')) { - return `/academy/search?type=video&category=${slugify(category)}` + return `/academy/search?type=video&category=${encodeURIComponent(slugify(category))}` } if (isBrowser() && window.location.pathname.includes('/academy/blog')) { - return `/academy/search?type=article&category=${slugify(category)}` + return `/academy/search?type=article&category=${encodeURIComponent(slugify(category))}` } - return `/academy/search?category=${slugify(category)}` + return `/academy/search?category=${encodeURIComponent(slugify(category))}` } return ( diff --git a/src/pages/academy/search/index.tsx b/src/pages/academy/search/index.tsx index 13a070fabc6..0dd15fe0add 100644 --- a/src/pages/academy/search/index.tsx +++ b/src/pages/academy/search/index.tsx @@ -290,6 +290,24 @@ const SearchPage = () => { : total_article } of ${total_article} results` + // This is a temporary solution without adding slug to the combined_filter_type + // array from the constant file. This can be refactored in the future but + // requires a change in the logic for both SearchBanner and search page. + const getCategoryText = () => { + switch (category_type) { + case 'cfds': + return 'CFDs' + case 'dbot': + return 'DBot' + case 'dtrader': + return 'DTrader' + case 'deriv-mt5': + return 'Deriv MT5' + default: + return unslugify(category_type) + } + } + return ( { Selection for
- {unslugify(category_type)} + {getCategoryText()}
)}