Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix encoding:null change

  • Loading branch information...
commit 99de83dcc2b5f94a3aa30338a38019ed1387676f 1 parent c3b3c96
@sylvinus authored
Showing with 22 additions and 2 deletions.
  1. +4 −2 lib/crawler.js
  2. +18 −0 test/units/simple.js
View
6 lib/crawler.js
@@ -21,7 +21,7 @@ if (!iconv) {
}
-exports.VERSION = "0.2.3";
+exports.VERSION = "0.2.4";
exports.Crawler = function(options) {
@@ -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) {
@@ -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 {
View
18 test/units/simple.js
@@ -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");
+
+});
+
/* */
Please sign in to comment.
Something went wrong with that request. Please try again.