diff --git a/frappe/public/js/frappe/ui/toolbar/fuzzy_match.js b/frappe/public/js/frappe/ui/toolbar/fuzzy_match.js
index 0d122faad4..59fccbccc5 100644
--- a/frappe/public/js/frappe/ui/toolbar/fuzzy_match.js
+++ b/frappe/public/js/frappe/ui/toolbar/fuzzy_match.js
@@ -31,7 +31,7 @@ const UNMATCHED_LETTER_PENALTY = -1;
* @returns [boolean, number] a boolean which tells if pattern was
* found or not and a search score
*/
-function fuzzy_match(pattern, str) {
+export function fuzzy_match(pattern, str) {
const recursion_count = 0;
const recursion_limit = 10;
const matches = [];
@@ -42,7 +42,7 @@ function fuzzy_match(pattern, str) {
str,
0 /* pattern_cur_index */,
0 /* str_curr_index */,
- null /* src_matces */,
+ null /* src_matches */,
matches,
max_matches,
0 /* next_match */,
@@ -56,7 +56,7 @@ function fuzzy_match_recursive(
str,
pattern_cur_index,
str_curr_index,
- src_matces,
+ src_matches,
matches,
max_matches,
next_match,
@@ -91,8 +91,8 @@ function fuzzy_match_recursive(
return [false, out_score];
}
- if (first_match && src_matces) {
- matches = [...src_matces];
+ if (first_match && src_matches) {
+ matches = [...src_matches];
first_match = false;
}
@@ -116,7 +116,7 @@ function fuzzy_match_recursive(
best_recursive_matches = [...recursive_matches];
best_recursive_score = recursive_score;
}
- recursiveMatch = true;
+ recursive_match = true;
}
matches[next_match++] = str_curr_index;
@@ -189,8 +189,3 @@ function fuzzy_match_recursive(
}
return [false, out_score];
}
-
-
-module.exports = {
- fuzzy_match
-};
diff --git a/frappe/public/js/frappe/ui/toolbar/search_utils.js b/frappe/public/js/frappe/ui/toolbar/search_utils.js
index c9fe3f85a8..db411feffd 100644
--- a/frappe/public/js/frappe/ui/toolbar/search_utils.js
+++ b/frappe/public/js/frappe/ui/toolbar/search_utils.js
@@ -540,36 +540,36 @@ frappe.search.utils = {
},
bolden_match_part: function(str, subseq) {
- if(fuzzy_match(subseq, str)[0] === false) {
+ if (fuzzy_match(subseq, str)[0] === false) {
return str;
}
- if(str.indexOf(subseq) == 0) {
- var tail = str.split(subseq)[1];
- return '' + subseq + '' + tail;
+ if (str.indexOf(subseq) == 0) {
+ var tail = str.split(subseq)[1];
+ return '' + subseq + '' + tail;
}
var rendered = "";
var str_orig = str;
- var str = str.toLowerCase();
var str_len = str.length;
- var subseq = subseq.toLowerCase();
-
- outer: for(var i = 0, j = 0; i < subseq.length; i++) {
- var sub_ch = subseq.charCodeAt(i);
- while(j < str_len) {
- if(str.charCodeAt(j) === sub_ch) {
- var str_char = str_orig.charAt(j);
- if(str_char === str_char.toLowerCase()) {
- rendered += '' + subseq.charAt(i) + '';
- } else {
- rendered += '' + subseq.charAt(i).toUpperCase() + '';
- }
- j++;
- continue outer;
- }
- rendered += str_orig.charAt(j);
- j++;
- }
- return str_orig;
+ str = str.toLowerCase();
+ subseq = subseq.toLowerCase();
+
+ outer: for (var i = 0, j = 0; i < subseq.length; i++) {
+ var sub_ch = subseq.charCodeAt(i);
+ while (j < str_len) {
+ if (str.charCodeAt(j) === sub_ch) {
+ var str_char = str_orig.charAt(j);
+ if (str_char === str_char.toLowerCase()) {
+ rendered += '' + subseq.charAt(i) + '';
+ } else {
+ rendered += '' + subseq.charAt(i).toUpperCase() + '';
+ }
+ j++;
+ continue outer;
+ }
+ rendered += str_orig.charAt(j);
+ j++;
+ }
+ return str_orig;
}
rendered += str_orig.slice(j);
return rendered;