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