codebyam commited on
Commit
16a6942
·
verified ·
1 Parent(s): 8334da6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1112,8 +1112,14 @@ async def read_items():
1112
  function hl(text, q) {
1113
  const e = esc(text);
1114
  if (!q) return e;
1115
- const re = new RegExp(esc(q).replace(/[.*+?^${}()|[\]/\/\]/g, "/\/\$&"), "gi");
1116
- return e.replace(re, (m) => `<mark>${m}</mark>`);
 
 
 
 
 
 
1117
  }
1118
 
1119
  function renderList() {
 
1112
  function hl(text, q) {
1113
  const e = esc(text);
1114
  if (!q) return e;
1115
+ const needle = esc(q).toLowerCase();
1116
+ const hay = e.toLowerCase();
1117
+ let out = "", i = 0, j;
1118
+ while ((j = hay.indexOf(needle, i)) !== -1) {
1119
+ out += e.slice(i, j) + "<mark>" + e.slice(j, j + needle.length) + "</mark>";
1120
+ i = j + needle.length;
1121
+ }
1122
+ return out + e.slice(i);
1123
  }
1124
 
1125
  function renderList() {