Skip to content

Commit

Permalink
Fixed searching for terms with a - (negative sign) in front, you must…
Browse files Browse the repository at this point in the history
… quote the string to find it, i.e. "-9999"
  • Loading branch information
remy committed Dec 23, 2009
1 parent 9ad6072 commit d3af7bb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions twitterlib.js
Expand Up @@ -207,8 +207,17 @@
var blocks = [], ors = [], ands = [], i = 0, negative = [], since = '', until = '';

search.replace(/(-?["'](.*?)["']|\S+\b)/g, function (m) {
var neg = false;
if (m.substr(0, 1) == '-') {
neg = true;
}
m = m.replace(/["']+|["']+$/g, '');
blocks.push(m);

if (neg) {
negative.push(m.substr(1).toLowerCase());
} else {
blocks.push(m);
}
});

for (i = 0; i < blocks.length; i++) {
Expand All @@ -217,8 +226,6 @@
ors.push(blocks[i+1].toLowerCase());
i++;
ands.pop(); // remove the and test from the last loop
} else if (blocks[i].substr(0, 1) == '-') {
negative.push(blocks[i].substr(1).toLowerCase());
} else {
ands.push(blocks[i].toLowerCase());
}
Expand Down

0 comments on commit d3af7bb

Please sign in to comment.