Skip to content

Commit 3506649

Browse files
committed
Refactor function
1 parent 1923e6f commit 3506649

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/format.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ function replaceHighlightTags(
66
highlightPreTag?: string,
77
highlightPostTag?: string
88
): string {
9-
let newHighlightValue = JSON.stringify(value) || ''
109
// If the value of the attribute is a string,
1110
// the highlight is applied by MeiliSearch (<em> tags)
1211
// and we replace the <em> by the expected tag for InstantSearch
13-
highlightPreTag = highlightPreTag || '__ais-highlight__'
14-
highlightPostTag = highlightPostTag || '__/ais-highlight__'
1512
if (isString(value)) {
16-
newHighlightValue = value
13+
highlightPreTag = highlightPreTag || '__ais-highlight__'
14+
highlightPostTag = highlightPostTag || '__/ais-highlight__'
15+
return value
1716
.replace(/<em>/g, highlightPreTag)
1817
.replace(/<\/em>/g, highlightPostTag)
1918
}
20-
return newHighlightValue.toString()
19+
return value
2120
}
2221

2322
function createHighlighResult<T extends Record<string, any>>({

0 commit comments

Comments
 (0)