Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
alias: {
o: 'outfile',
},
}
);
if (cli.flags.limitSimilar) {
if (!Number.isInteger(cli.flags.limitSimilar)) {
// Set default if true
cli.flags.limitSimilar = 3;
}
}
if (cli.flags.referenceUrl) {
if (!validurl(cli.flags.referenceUrl)) {
console.error(
`> Error: "${cli.flags.referenceUrl}" isn't a valid reference URL`
);
process.exit(1);
}
}
if (cli.input.length > 0) {
if (validurl(cli.input[0])) {
crawl(cli.input[0], cli.flags);
} else {
console.error(`> Error: "${cli.input[0]}" isn't a valid URL`);
process.exit(1);
}
} else {
cli.showHelp();
var start_url = function(opts, callback) {
var $ = cheerio.load(opts.html);
var url = opts.url;
var startUrl = $('link[rel=start]').attr('href');
if (!startUrl) {
startUrl = $('[name=msapplication-starturl]').attr('content');
}
if (!startUrl) {
if (url && !isUrl(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the start_url we want to use
startUrl = url;
}
else if (isUrl(url)) {
// if we have a valid url, then its more likely that we were given the homepage
// for the app. So the path is the most likely canidate for the start_url
startUrl = _url.parse(url).path;
}
else {
// I can't think of a better default
startUrl = '/';
}
}
if (callback) {
const start_url = (opts, callback) => {
const $ = Cheerio.load(opts.html);
const url = opts.url;
let startUrl = $('link[rel=start]').attr('href');
if (!startUrl) {
startUrl = $('[name=msapplication-starturl]').attr('content');
}
if (!startUrl) {
if (url && !IsURL(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the start_url we want to use
startUrl = url;
}
else if (IsURL(url)) {
// if we have a valid url, then its more likely that we were given the homepage
// for the app. So the path is the most likely canidate for the start_url
startUrl = Url.parse(url).path;
}
else {
// I can't think of a better default
startUrl = '/';
}
}
if (callback) {
var $ = cheerio.load(opts.html);
var url = opts.url;
var startUrl = $('link[rel=start]').attr('href');
if (!startUrl) {
startUrl = $('[name=msapplication-starturl]').attr('content');
}
if (!startUrl) {
if (url && !isUrl(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the start_url we want to use
startUrl = url;
}
else if (isUrl(url)) {
// if we have a valid url, then its more likely that we were given the homepage
// for the app. So the path is the most likely canidate for the start_url
startUrl = _url.parse(url).path;
}
else {
// I can't think of a better default
startUrl = '/';
}
}
if (callback) {
callback(null, startUrl);
}
return startUrl;
};
var scope = function(obj, callback) {
var url = obj.url;
var _scope;
if (url && !isUrl(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the scope we want to use
_scope = url;
}
else if (isUrl(url)) {
// if we have a valid url, then its more liekly that we were given the homepage
// for the app. So the path is the most liekly canidate for the scope
_scope = _url.parse(url).path;
}
else {
// I can't think of a better default
_scope = '/';
}
if (callback) {
callback(null, _scope);
const scope = (obj, callback) => {
const url = obj.url;
let _scope;
if (url && !IsURL(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the scope we want to use
_scope = url;
}
else if (IsURL(url)) {
// if we have a valid url, then its more liekly that we were given the homepage
// for the app. So the path is the most liekly canidate for the scope
_scope = Url.parse(url).path;
}
else {
// I can't think of a better default
_scope = '/';
}
if (callback) {
callback(null, _scope);
}
return _scope;
};
var scope = function(obj, callback) {
var url = obj.url;
var _scope;
if (url && !isUrl(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the scope we want to use
_scope = url;
}
else if (isUrl(url)) {
// if we have a valid url, then its more liekly that we were given the homepage
// for the app. So the path is the most liekly canidate for the scope
_scope = _url.parse(url).path;
}
else {
// I can't think of a better default
_scope = '/';
}
if (callback) {
callback(null, _scope);
}
return _scope;
};
const $ = Cheerio.load(opts.html);
const url = opts.url;
let startUrl = $('link[rel=start]').attr('href');
if (!startUrl) {
startUrl = $('[name=msapplication-starturl]').attr('content');
}
if (!startUrl) {
if (url && !IsURL(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the start_url we want to use
startUrl = url;
}
else if (IsURL(url)) {
// if we have a valid url, then its more likely that we were given the homepage
// for the app. So the path is the most likely canidate for the start_url
startUrl = Url.parse(url).path;
}
else {
// I can't think of a better default
startUrl = '/';
}
}
if (callback) {
callback(null, startUrl);
}
return startUrl;
};
const scope = (obj, callback) => {
const url = obj.url;
let _scope;
if (url && !IsURL(url)) {
// if the url exists and is not a valid wbe url (e.g. /foo), then
// its probably the scope we want to use
_scope = url;
}
else if (IsURL(url)) {
// if we have a valid url, then its more liekly that we were given the homepage
// for the app. So the path is the most liekly canidate for the scope
_scope = Url.parse(url).path;
}
else {
// I can't think of a better default
_scope = '/';
}
if (callback) {
callback(null, _scope);
cli.flags.limitSimilar = 3;
}
}
if (cli.flags.referenceUrl) {
if (!validurl(cli.flags.referenceUrl)) {
console.error(
`> Error: "${cli.flags.referenceUrl}" isn't a valid reference URL`
);
process.exit(1);
}
}
if (cli.input.length > 0) {
if (validurl(cli.input[0])) {
crawl(cli.input[0], cli.flags);
} else {
console.error(`> Error: "${cli.input[0]}" isn't a valid URL`);
process.exit(1);
}
} else {
cli.showHelp();
}