This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,6 @@ export const slugify = (text) =>
345
345
. toLowerCase ( )
346
346
. trim ( ) // Remove whitespace from both sides of a string
347
347
. replace ( / \s + / g, '-' ) // Replace spaces with -
348
- . replace ( / [ ^ \w - ] + / g, '' ) // Remove all non-word chars
349
348
. replace ( / - - + / g, '-' ) // Replace multiple - with single -
350
349
351
350
export const unslugify = ( slug ) => {
Original file line number Diff line number Diff line change @@ -749,12 +749,12 @@ const SearchBanner = ({ hidden }: SearchBannerProps) => {
749
749
750
750
const handleHref = ( category ) => {
751
751
if ( isBrowser ( ) && window . location . pathname . includes ( '/academy/videos' ) ) {
752
- return `/academy/search?type=video&category=${ slugify ( category ) } `
752
+ return `/academy/search?type=video&category=${ encodeURIComponent ( slugify ( category ) ) } `
753
753
}
754
754
if ( isBrowser ( ) && window . location . pathname . includes ( '/academy/blog' ) ) {
755
- return `/academy/search?type=article&category=${ slugify ( category ) } `
755
+ return `/academy/search?type=article&category=${ encodeURIComponent ( slugify ( category ) ) } `
756
756
}
757
- return `/academy/search?category=${ slugify ( category ) } `
757
+ return `/academy/search?category=${ encodeURIComponent ( slugify ( category ) ) } `
758
758
}
759
759
760
760
return (
Original file line number Diff line number Diff line change @@ -290,6 +290,24 @@ const SearchPage = () => {
290
290
: total_article
291
291
} of ${ total_article } results`
292
292
293
+ // This is a temporary solution without adding slug to the combined_filter_type
294
+ // array from the constant file. This can be refactored in the future but
295
+ // requires a change in the logic for both SearchBanner and search page.
296
+ const getCategoryText = ( ) => {
297
+ switch ( category_type ) {
298
+ case 'cfds' :
299
+ return 'CFDs'
300
+ case 'dbot' :
301
+ return 'DBot'
302
+ case 'dtrader' :
303
+ return 'DTrader'
304
+ case 'deriv-mt5' :
305
+ return 'Deriv MT5'
306
+ default :
307
+ return unslugify ( category_type )
308
+ }
309
+ }
310
+
293
311
return (
294
312
< Layout type = "academy" margin_top = { '14.4' } >
295
313
< SEO
@@ -320,7 +338,7 @@ const SearchPage = () => {
320
338
Selection for
321
339
</ Header >
322
340
< Header type = "heading-2" as = "span" color = "black-3" weight = "normal" >
323
- { unslugify ( category_type ) }
341
+ { getCategoryText ( ) }
324
342
</ Header >
325
343
</ >
326
344
) }
You can’t perform that action at this time.
0 commit comments