La-Lojban / sutysisku

la sutysisku dictionary for Lojban and more
https://la-lojban.github.io/sutysisku/lojban/
MIT License
35 stars 7 forks source link

uncaught exception on multi-word search #8

Closed erisdev closed 7 years ago

erisdev commented 7 years ago

tested in:

sisku.js:5 Uncaught TypeError: Cannot read property 'search' of undefined
    at ma_klesi_lo_valsi (https://la-lojban.github.io/sutysisku/sisku.js:5:36)
    at jmina_lo_se_claxu (https://la-lojban.github.io/sutysisku/sisku.js:53:16)
    at https://la-lojban.github.io/sutysisku/sisku.js:87:14
    at Array.map (native)
    at julne (https://la-lojban.github.io/sutysisku/sisku.js:86:8)
    at sisku (https://la-lojban.github.io/sutysisku/sisku.js:325:23)
    at onmessage (https://la-lojban.github.io/sutysisku/en/worker.js:6:94)
erisdev commented 7 years ago

lagleki/glekitufa@05e5019a4e888d18c075e706cc2ffadf6b78943f appears to be the commit that broke it

erisdev commented 7 years ago

this fixes multi-word searches, but special search queries are still broken.

diff --git a/sutysisku/sisku.js b/sutysisku/sisku.js
index 826b0d9e..34396ffd 100644
--- a/sutysisku/sisku.js
+++ b/sutysisku/sisku.js
@@ -57,6 +57,10 @@ function jmina_lo_se_claxu(doc) {
   return doc;
 }

+Object.keys(sorcu[bau]).forEach(function(a) {
+    sorcu[bau][a].w = a;
+});
+
 window.storecache = {};
 for (var i in sorcu[bau]){
   window.storecache[i]=i+";"+Object.keys(sorcu[bau][i]).map(function(b) {
@@ -232,6 +236,8 @@ function sisku(query, callback) {
     a = a.replace(/([aeiouy])\1/igm, "$1'$1");
     var isdef = Object.keys(sorcu[bau]).filter(function(o) {
       return (o.toLowerCase() === a.toLowerCase()) || (sorcu[bau][o]["d"].toLowerCase() === "{" + a.toLowerCase() + "}");
+    }).map(function(valsi) {
+        return sorcu[bau][valsi];
     });
     if (isdef && isdef.length > 0) {
       ki = ki.concat(isdef);
lagleki commented 7 years ago

fixed via https://github.com/lagleki/glekitufa/commit/bc503f627d5385f74c3fb1238ea141c423762b38 https://github.com/lagleki/glekitufa/commit/e4b6316c15fc2aa0b2591111d4bd44101e9620ae https://github.com/lagleki/glekitufa/commit/154a69e0581663fd542ff38a8acb90303adb8220