popomore / projj

Manage repository easily.
MIT License
266 stars 40 forks source link

find 为什么要优先匹配 endsWith('/{keyword}') ? #48

Open hotoo opened 5 years ago

hotoo commented 5 years ago

比如我有 "abc" 和 "tiny-abc" 两个仓库,"abc" 是常用的关键字,但是 projj find abc 始终只能搜到 "abc"。

    const keys = Object.keys(yield this.cache.get());
    let matched = keys.filter(key => key.endsWith(repo.replace(/^\/?/, '/')));
    if (!matched.length) matched = keys.filter(key => key.indexOf(repo) >= 0);

我觉得搜索结果应该将所有命中的都返回,只是排序上可以有侧重。

hotoo commented 5 years ago

@popomore 看看