Skip to content

Commit ed8f8ac

Browse files
author
Evgheni C.
committed
Merge pull request #6 from NetCrafters/master
Handle invalid links and empty responds bodies
2 parents 6929d14 + f0eed66 commit ed8f8ac

File tree

7 files changed

+2809
-1323
lines changed

7 files changed

+2809
-1323
lines changed

crawling-daemon.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ function checkUrl()
218218
return;
219219
}
220220

221+
if (!body) {
222+
processingDOM = false;
223+
return;
224+
}
225+
221226
jsdom.env({
222227
html: body,
223228
scripts: ["http://code.jquery.com/jquery.js"],
@@ -236,6 +241,10 @@ function checkUrl()
236241

237242
$("a").each(function()
238243
{
244+
if (typeof($(this).attr('href'))=='undefined') {
245+
processingDOM = (--links_found > 0);
246+
return;
247+
}
239248
var lnk = $(this).attr("href").replace(new RegExp("#(.*)"), "");
240249

241250
if ((lnk = check_link(lnk)) == false) {

0 commit comments

Comments
 (0)