git ssb

0+

mixmix / ssb-meme



Commit 0ed559744790dca3e81c14bc14db092ea1fc626c

consistent spliting of search phrase

mix irving committed on 5/28/2018, 10:51:15 PM
Parent: b848b4be1ba7f602add5be6e000f787eaee31a77

Files changed

index.jschanged
index.jsView
@@ -6,8 +6,11 @@
66
77 const INDEX_VERSION = 2
88 const SEARCH_TERM_MIN = 3
99
10 +const imgExtRegEx = /\.(jpg|jpeg|png|gif|bmp|svg)$/i
11 +const spaceCharRegex = /(-|\.|_|\/|~|\s)/g
12 +
1013 module.exports = {
1114 name: 'meme',
1215 version: require('./package.json').version,
1316 manifest: {
@@ -24,10 +27,13 @@
2427
2528 function search (opts, cb) {
2629 if (typeof opts === 'string') opts = { query: opts }
2730 opts.query = opts.query.toLowerCase()
28- const validTerms = opts.query.split(' ').filter(s => s.length >= SEARCH_TERM_MIN)
2931
32 + const validTerms = opts.query
33 + .split(spaceCharRegex)
34 + .filter(s => s.length >= SEARCH_TERM_MIN)
35 +
3036 pull(
3137 view.query(opts),
3238 pull.collect((err, data) => {
3339 if (err) return cb(err)
@@ -56,11 +62,8 @@
5662 }
5763 }
5864 }
5965
60-const imgExtRegEx = /\.(jpg|jpeg|png|gif|bmp|svg)$/i
61-const spaceCharRegex = /(-|\.|_|\/|~)/g
62-
6366 function map (msg) {
6467 return getMentions(msg)
6568 .filter(isBlobMention)
6669 .map(m => m.name)

Built with git-ssb-web