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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umberto",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "CKSource Documentation builder",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -115,7 +115,12 @@ export function setUpFuse() {
115
115
 
116
116
  function addHighlight( text, searchedQuery ) {
117
117
  const highlightClass = 'algolia-docsearch-suggestion--highlight';
118
- const queryRegex = new RegExp( `(${ searchedQuery })`, 'gi' );
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
  }