File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -11,22 +11,21 @@ import { InstantSearchParams } from '../types'
11
11
* @returns string
12
12
*/
13
13
function replaceHighlightTags (
14
- value : string ,
14
+ value : any ,
15
15
highlightPreTag ?: string ,
16
16
highlightPostTag ?: string
17
17
) : string {
18
- // Value has to be a string to have highlight.
19
- // Highlight is applied by MeiliSearch (<em> tags)
20
- // We replace the <em> by the expected tag for InstantSearch
21
18
highlightPreTag = highlightPreTag || '__ais-highlight__'
22
19
highlightPostTag = highlightPostTag || '__/ais-highlight__'
23
- if ( isString ( value ) ) {
24
- return value
25
- . replace ( / < e m > / g, highlightPreTag )
26
- . replace ( / < \/ e m > / g, highlightPostTag )
27
- }
28
- // We JSON stringify to avoid loss of nested information
29
- return JSON . stringify ( value )
20
+ // Highlight is applied by MeiliSearch (<em> tags)
21
+ // We replace the <em> by the expected tag for InstantSearch
22
+ const stringifiedValue = isString ( value )
23
+ ? value
24
+ : JSON . stringify ( value , null , 2 )
25
+
26
+ return stringifiedValue
27
+ . replace ( / < e m > / g, highlightPreTag )
28
+ . replace ( / < \/ e m > / g, highlightPostTag )
30
29
}
31
30
32
31
/**
You can’t perform that action at this time.
0 commit comments