File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,18 @@ function replaceHighlightTags(
66 highlightPreTag ?: string ,
77 highlightPostTag ?: string
88) : string {
9- // Value has to be a string.
10- // Some field may have highlight applied by MeiliSearch (<em> tags)
9+ // Value has to be a string to have highlight .
10+ // Highlight is applied by MeiliSearch (<em> tags)
1111 // We replace the <em> by the expected tag for InstantSearch
1212 highlightPreTag = highlightPreTag || '__ais-highlight__'
1313 highlightPostTag = highlightPostTag || '__/ais-highlight__'
14+ if ( isString ( value ) ) {
15+ return value
16+ . replace ( / < e m > / g, highlightPreTag )
17+ . replace ( / < \/ e m > / g, highlightPostTag )
18+ }
19+ // We JSON stringify to avoid loss of nested information
1420 return JSON . stringify ( value )
15- . replace ( / < e m > / g, highlightPreTag )
16- . replace ( / < \/ e m > / g, highlightPostTag )
1721}
1822
1923function createHighlighResult < T extends Record < string , any > > ( {
You can’t perform that action at this time.
0 commit comments