Commit 0ed559744790dca3e81c14bc14db092ea1fc626c
consistent spliting of search phrase
mix irving committed on 5/28/2018, 10:51:15 PMParent: b848b4be1ba7f602add5be6e000f787eaee31a77
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -6,8 +6,11 @@ | ||
6 | 6 … | |
7 | 7 … | const INDEX_VERSION = 2 |
8 | 8 … | const SEARCH_TERM_MIN = 3 |
9 | 9 … | |
10 … | +const imgExtRegEx = /\.(jpg|jpeg|png|gif|bmp|svg)$/i | |
11 … | +const spaceCharRegex = /(-|\.|_|\/|~|\s)/g | |
12 … | + | |
10 | 13 … | module.exports = { |
11 | 14 … | name: 'meme', |
12 | 15 … | version: require('./package.json').version, |
13 | 16 … | manifest: { |
@@ -24,10 +27,13 @@ | ||
24 | 27 … | |
25 | 28 … | function search (opts, cb) { |
26 | 29 … | if (typeof opts === 'string') opts = { query: opts } |
27 | 30 … | opts.query = opts.query.toLowerCase() |
28 | - const validTerms = opts.query.split(' ').filter(s => s.length >= SEARCH_TERM_MIN) | |
29 | 31 … | |
32 … | + const validTerms = opts.query | |
33 … | + .split(spaceCharRegex) | |
34 … | + .filter(s => s.length >= SEARCH_TERM_MIN) | |
35 … | + | |
30 | 36 … | pull( |
31 | 37 … | view.query(opts), |
32 | 38 … | pull.collect((err, data) => { |
33 | 39 … | if (err) return cb(err) |
@@ -56,11 +62,8 @@ | ||
56 | 62 … | } |
57 | 63 … | } |
58 | 64 … | } |
59 | 65 … | |
60 | -const imgExtRegEx = /\.(jpg|jpeg|png|gif|bmp|svg)$/i | |
61 | -const spaceCharRegex = /(-|\.|_|\/|~)/g | |
62 | - | |
63 | 66 … | function map (msg) { |
64 | 67 … | return getMentions(msg) |
65 | 68 … | .filter(isBlobMention) |
66 | 69 … | .map(m => m.name) |
Built with git-ssb-web