REFACTOR: Remove `_.reject`
This commit is contained in:
parent
2a4dfa83b0
commit
87b3caf927
|
@ -59,8 +59,10 @@ export default Controller.extend({
|
|||
if (!q) {
|
||||
return;
|
||||
}
|
||||
// remove l which can be used for sorting
|
||||
return _.reject(q.split(/\s+/), t => t === "l").join(" ");
|
||||
return q
|
||||
.split(/\s+/)
|
||||
.filter(t => t !== "l")
|
||||
.join(" ");
|
||||
},
|
||||
|
||||
@discourseComputed("skip_context", "context")
|
||||
|
|
|
@ -7,12 +7,11 @@ export const CLASS_NAME = "search-highlight";
|
|||
export default function(elem, term, opts = {}) {
|
||||
if (!isEmpty(term)) {
|
||||
// special case ignore "l" which is used for magic sorting
|
||||
let words = _.reject(
|
||||
term.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g")),
|
||||
t => t === "l"
|
||||
);
|
||||
let words = term
|
||||
.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g"))
|
||||
.filter(t => t !== "l")
|
||||
.map(w => w.replace(/^"(.*)"$/, "$1"));
|
||||
|
||||
words = words.map(w => w.replace(/^"(.*)"$/, "$1"));
|
||||
const highlightOpts = {};
|
||||
if (!opts.defaultClassName) highlightOpts.className = CLASS_NAME;
|
||||
highlightHTML(elem, words, highlightOpts);
|
||||
|
|
Loading…
Reference in New Issue