Fixed error when search term contained parentheses

This commit is contained in:
squidfunk
2017-03-24 19:37:39 +01:00
committed by Martin Donath
parent c732082a1c
commit de54e6e800
6 changed files with 38 additions and 6 deletions

View File

@@ -20,6 +20,7 @@
* IN THE SOFTWARE.
*/
import escape from "escape-string-regexp"
import lunr from "lunr"
/* ----------------------------------------------------------------------------
@@ -184,7 +185,7 @@ export default class Result {
/* Assemble highlight regex from query string */
const match = new RegExp(
`\\b(${this.value_.trim().replace(" ", "|")})`, "img")
`\\b(${escape(this.value_.trim().replace(" ", "|"))})`, "img")
const highlight = string => `<em>${string}</em>`
/* Render results */