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'
1111 * @returns string
1212 */
1313function replaceHighlightTags (
14- value : string ,
14+ value : any ,
1515 highlightPreTag ?: string ,
1616 highlightPostTag ?: string
1717) : 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
2118 highlightPreTag = highlightPreTag || '__ais-highlight__'
2219 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 )
3029}
3130
3231/**
You can’t perform that action at this time.
0 commit comments