diff options
author | Joe Robinson <joe@lc8n.com> | 2015-12-05 18:44:59 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2015-12-05 18:44:59 +0000 |
commit | 48eb01696d0adc16a66dbf560f5c5771f6ea5428 (patch) | |
tree | 013cbd268ee238893b1aa7eefa0dd2114ebfd284 /search.js | |
parent | ff74f82dff02a8e2676aa30fef85adfea02dfc5a (diff) |
Diffstat (limited to 'search.js')
-rw-r--r-- | search.js | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -12,12 +12,11 @@ var options = { headers: { "Cookie": cookie } }; -var query = 'beans' +var query = process.argv.slice(2,process.argv.length) function result(error, response, body) { if (!error && response.statusCode == 200) { var results = JSON.parse(body); - //console.log(results); search(query, results); } } @@ -25,10 +24,22 @@ function result(error, response, body) { function search(query, json) { json.forEach(function(item) { - if (item.filename.search(query) > 0) { + if (matches(query, item.filename)) { console.log(item.filename); } }); } +function matches(query, filename) { + + var matches = true; + query.forEach(function(word) { + if(filename.search(word) == -1) { + matches = false; + return; + } + }); + return matches; +} + request(options, result); |