summaryrefslogtreecommitdiff
path: root/search.js
diff options
context:
space:
mode:
Diffstat (limited to 'search.js')
-rw-r--r--search.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/search.js b/search.js
index fda4604..e693bad 100644
--- a/search.js
+++ b/search.js
@@ -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);