terasum / js-mdict

*.mdx/*.mdd interpreter js implements, support mdict index file
MIT License
154 stars 18 forks source link

mdict.js _findList 返回值可能是 undefined,后续取值会报错 #66

Closed tonyzhou1890 closed 1 year ago

tonyzhou1890 commented 2 years ago
  _findList(word) {
    const findListInternal = (compareFn) => {
      const sfunc = this._stripKey();
      const kbid = this._reduceWordKeyBlock(word, sfunc, compareFn);
      // not found
      if (kbid < 0) {
        return undefined;
      }
      return { sfunc, kbid, list: this._decodeKeyBlockByKBID(kbid) };
    };

    let list;
    if (this._isKeyCaseSensitive()) {
      list = findListInternal(common.normalUpperCaseWordCompare);
    } else {
      list = findListInternal(common.normalUpperCaseWordCompare);
      if (list === undefined) {
        list = findListInternal(common.wordCompare);
      }
    }
    return list;
  }

findListInternal 会返回 undefined,后续操作报错,比如:this._findList(phrase).list

terasum commented 2 years ago

感谢反馈,我会尽快修复该问题

terasum commented 1 year ago

本问题已经修复。