mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
typeahead_helper: Use _.escapeRegExp in build_highlight_regex.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
1be2cf6d8a
commit
018b4fece4
@@ -1,4 +1,5 @@
|
|||||||
const Handlebars = require("handlebars/runtime");
|
const Handlebars = require("handlebars/runtime");
|
||||||
|
const _ = require("lodash");
|
||||||
|
|
||||||
const pygments_data = require("../generated/pygments_data.json");
|
const pygments_data = require("../generated/pygments_data.json");
|
||||||
const emoji = require("../shared/js/emoji");
|
const emoji = require("../shared/js/emoji");
|
||||||
@@ -17,9 +18,7 @@ exports.get_cleaned_pm_recipients = function (query_string) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.build_highlight_regex = function (query) {
|
exports.build_highlight_regex = function (query) {
|
||||||
// the regex below is based on bootstrap code
|
const regex = new RegExp("(" + _.escapeRegExp(query) + ")", "ig");
|
||||||
query = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
||||||
const regex = new RegExp("(" + query + ")", "ig");
|
|
||||||
return regex;
|
return regex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user