Socket
Socket
Sign inDemoInstall

@belym.a.2105/broken-link-checker

Package Overview
Dependencies
22
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.9 to 0.7.10-alpha.1

lib/internal/BufferStream.js

11

lib/internal/getRobotsTxt.js
"use strict";
var guard = require("robots-txt-guard");
var parse = require("robots-txt-parse");
var BufferStream = require('./BufferStream');

@@ -14,3 +15,3 @@ var got = require("got");

url = urlobj.parse(url);
// TODO :: this mutates the original (if was an object)

@@ -21,3 +22,3 @@ url.hash = null;

url.search = null;
var stream = new Promise((resolve, reject) => {

@@ -31,4 +32,8 @@ const request = got(urllib.format(url), // TODO :: https://github.com/joepie91/node-bhttp/issues/3

const buf = new BufferStream();
request.pipe(buf);
request.on('error', reject);
request.on('response', resolve);
request.on('response', () => resolve(buf));
});

@@ -35,0 +40,0 @@

@@ -11,3 +11,3 @@ "use strict";

var result = treeAdapter.createElement_old(tagName, namespaceURI, attrs);
if (result.attrs != null)

@@ -17,3 +17,3 @@ {

}
return result;

@@ -28,3 +28,3 @@ };

Convert attributes array to a map.
Note: parse5 will have already handled multiple attrs of the

@@ -38,3 +38,3 @@ same name.

var numAttrs = attrs.length;
for (i=0; i<numAttrs; i++)

@@ -44,3 +44,3 @@ {

}
return map;

@@ -61,3 +61,3 @@ }

var parser = new parse5.ParserStream(options);
parser.on("finish", function()

@@ -67,3 +67,3 @@ {

});
input.pipe(parser);

@@ -70,0 +70,0 @@ }

"use strict";
var BufferStream = require('./BufferStream');
var errors = require("./messages").errors;

@@ -12,3 +13,3 @@ var simpleResponse = require("./simpleResponse");

var error,type;
if (response.statusCode !== 200)

@@ -20,5 +21,5 @@ {

}
type = response.headers["content-type"];
// content-type is not mandatory in HTTP spec

@@ -50,2 +51,7 @@ if (type==null || type.indexOf("text/html")!==0)

});
const buf = new BufferStream();
stream.pipe(buf);
var redirects = [];

@@ -61,13 +67,13 @@

var response = simpleResponse(orgResponse);
result = checkErrors(response);
if (result === undefined)
{
result =
result =
{
response: response,
stream: orgResponse
stream: buf
};
// Send response of redirected url to cache

@@ -80,3 +86,3 @@ if (options.cacheResponses===true && response.url!==url)

}
resolve(response);

@@ -90,3 +96,3 @@ });

});
// Send response to cache -- it will be available to `cache.get()` before being resolved

@@ -98,3 +104,3 @@ if (options.cacheResponses === true)

}
// Send result to caller

@@ -105,3 +111,3 @@ return request.then( function(response)

if (result instanceof Error === true) throw result;
return result;

@@ -108,0 +114,0 @@ });

@@ -20,8 +20,8 @@ "use strict";

var thisObj = this;
reset(this);
this.handlers = handlers || {};
this.options = options = parseOptions(options);
this.urlChecker = new UrlChecker(this.options,

@@ -85,3 +85,3 @@ {

var thisObj = this;
if (this.active === false)

@@ -94,7 +94,7 @@ {

}
this.active = true;
this.baseUrl = baseUrl;
this.robots = robots;
parseHtml(html).then( function(document)

@@ -108,3 +108,3 @@ {

maybeCallback(thisObj.handlers.html)(tree, thisObj.robots);
for (var i=0, numLinks=links.length; i<numLinks; i++)

@@ -114,5 +114,5 @@ {

}
thisObj.parsed = true;
// If no links found or all links already checked

@@ -124,6 +124,6 @@ if (thisObj.urlChecker.numActiveLinks()===0 && thisObj.urlChecker.numQueuedLinks()===0)

});
return true;
}
return false;

@@ -148,3 +148,3 @@ };

reset(instance);
maybeCallback(instance.handlers.complete)();

@@ -158,7 +158,7 @@ }

var excludedReason;
linkObj.resolve(link, instance.baseUrl, instance.options);
excludedReason = excludeLink(link, instance);
if (excludedReason !== false)

@@ -169,15 +169,15 @@ {

link.excludedReason = excludedReason;
linkObj.clean(link);
maybeCallback(instance.handlers.junk)(link);
return;
}
link.html.offsetIndex = link.html.index - instance.excludedLinks;
link.excluded = false;
instance.linkEnqueued = instance.urlChecker.enqueue(link);
// TODO :: is this redundant? maybe use `linkObj.invalidate()` in `excludeLink()` ?

@@ -189,5 +189,5 @@ if (instance.linkEnqueued instanceof Error)

link.brokenReason = instance.linkEnqueued.message==="Invalid URI" ? "BLC_INVALID" : "BLC_UNKNOWN";
linkObj.clean(link);
maybeCallback(instance.handlers.link)(link);

@@ -205,3 +205,3 @@ }

var tagGroup = instance.options.tags[instance.options.filterLevel][tagName];
if (tagGroup != null)

@@ -211,3 +211,3 @@ {

}
if (attrSupported !== true) return "BLC_HTML";

@@ -218,3 +218,3 @@ if (instance.options.excludeExternalLinks===true && link.internal===false) return "BLC_EXTERNAL";

if (instance.options.excludedSchemes[link.url.parsed.extra.protocolTruncated] === true) return "BLC_SCHEME";
if (instance.options.honorRobotExclusions === true)

@@ -226,9 +226,9 @@ {

}
if (instance.robots.is(RobotDirectives.NOIMAGEINDEX) === true)
{
if (
(tagName==="img" && attrName==="src" ) ||
(tagName==="input" && attrName==="src" ) ||
(tagName==="menuitem" && attrName==="icon" ) ||
(tagName==="img" && attrName==="src" ) ||
(tagName==="input" && attrName==="src" ) ||
(tagName==="menuitem" && attrName==="icon" ) ||
(tagName==="video" && attrName==="poster")

@@ -240,3 +240,3 @@ )

}
if (link.html.attrs!=null && link.html.attrs.rel!=null && linkTypes(link.html.attrs.rel).nofollow===true)

@@ -247,8 +247,8 @@ {

}
if (matchUrl(link.url.resolved, instance.options.excludedKeywords) === true) return "BLC_KEYWORD";
// Undocumented handler for custom constraints
externalFilter = maybeCallback(instance.handlers._filter)(link);
if (isString(externalFilter) === true)

@@ -262,3 +262,3 @@ {

}*/
return false;

@@ -265,0 +265,0 @@ }

{
"name": "@belym.a.2105/broken-link-checker",
"description": "Find broken links, missing images, etc in your HTML.",
"version": "0.7.9",
"version": "0.7.10-alpha.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc