Skip to content

Commit

Permalink
Fix encoding:null change
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvinus committed Feb 26, 2013
1 parent c3b3c96 commit 99de83d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!iconv) {
}


exports.VERSION = "0.2.3";
exports.VERSION = "0.2.4";

exports.Crawler = function(options) {

Expand Down Expand Up @@ -218,6 +218,8 @@ exports.Crawler = function(options) {
response.body = response.body.toString("utf8"); //hope for the best
}

} else {
response.body = response.body.toString();
}

if (useCache(toQueue) && !fromCache) {
Expand Down Expand Up @@ -272,7 +274,7 @@ exports.Crawler = function(options) {
// TODO cache this
fs.readFile(toQueue.jQueryUrl.replace(/^file\:\/\//,""),"utf-8",function(err,jq) {
if (err) {
toQueue.callback(e);
toQueue.callback(err);
release(toQueue);
} else {
try {
Expand Down
18 changes: 18 additions & 0 deletions test/units/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,23 @@ test("one request + user agent", function() {
});


test("from the readme",function() {

expect( 2 );

stop();

var c = new Crawler({
"maxConnections":10,
"callback":function(error,result,$) {
equal(typeof result.body, "string");
ok(result.body.indexOf("Google")>=0);
start();
}
});
c.queue("http://google.com");

});


/* */

0 comments on commit 99de83d

Please sign in to comment.