umberto 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -115,7 +115,12 @@ export function setUpFuse() {
|
|
|
115
115
|
|
|
116
116
|
function addHighlight( text, searchedQuery ) {
|
|
117
117
|
const highlightClass = 'algolia-docsearch-suggestion--highlight';
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions.
|
|
120
|
+
// See: #984.
|
|
121
|
+
const escapedQuery = searchedQuery.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
122
|
+
|
|
123
|
+
const queryRegex = new RegExp( `(${ escapedQuery })`, 'gi' );
|
|
119
124
|
|
|
120
125
|
return text.replace( queryRegex, `<span class="${ highlightClass }">$1</span>` );
|
|
121
126
|
}
|