diff options
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); |