Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

linkinator

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkinator - npm Package Compare versions

Comparing version 2.11.2 to 2.12.0

build/src/server.d.ts

6

build/src/cli.js

@@ -34,2 +34,6 @@ #!/usr/bin/env node

--directory-listing
Include an automatic directory index file when linking to a directory.
Defaults to 'false'.
--format, -f

@@ -79,2 +83,3 @@ Return the data in CSV or JSON format.

verbosity: { type: 'string' },
directoryListing: { type: 'boolean' },
},

@@ -120,2 +125,3 @@ booleanDefault: undefined,

serverRoot: flags.serverRoot,
directoryListing: flags.directoryListing,
};

@@ -122,0 +128,0 @@ if (flags.skip) {

1

build/src/config.d.ts

@@ -11,3 +11,4 @@ export interface Flags {

serverRoot?: string;
directoryListing?: boolean;
}
export declare function getConfig(flags: Flags): Promise<Flags>;

12

build/src/index.d.ts
/// <reference types="node" />
import { EventEmitter } from 'events';
import { URL } from 'url';
import PQueue, { DefaultAddOptions } from 'p-queue';
import { URL } from 'url';
import PriorityQueue from 'p-queue/dist/priority-queue';

@@ -15,2 +15,3 @@ export interface CheckOptions {

serverRoot?: string;
directoryListing?: boolean;
}

@@ -65,11 +66,2 @@ export declare enum LinkState {

/**
* Spin up a local HTTP server to serve static requests from disk
* @param root The local path that should be mounted as a static web server
* @param port The port on which to start the local web server
* @param markdown If markdown should be automatically compiled and served
* @private
* @returns Promise that resolves with the instance of the HTTP server
*/
private startWebServer;
/**
* Crawl a given url with the provided options.

@@ -76,0 +68,0 @@ * @pram opts List of options used to do the crawl

@@ -5,17 +5,12 @@ "use strict";

const events_1 = require("events");
const gaxios_1 = require("gaxios");
const http = require("http");
const enableDestroy = require("server-destroy");
const finalhandler = require("finalhandler");
const serveStatic = require("serve-static");
const url_1 = require("url");
const fs = require("fs");
const util = require("util");
const path = require("path");
const marked = require("marked");
const gaxios_1 = require("gaxios");
const p_queue_1 = require("p-queue");
const globby = require("glob");
const links_1 = require("./links");
const url_1 = require("url");
const server_1 = require("./server");
const stat = util.promisify(fs.stat);
const readFile = util.promisify(fs.readFile);
const glob = util.promisify(globby);

@@ -51,4 +46,8 @@ var LinkState;

const port = options.port || 5000 + Math.round(Math.random() * 1000);
server = await this.startWebServer(options.serverRoot, port, options.markdown);
enableDestroy(server);
server = await server_1.startWebServer({
root: options.serverRoot,
port,
markdown: options.markdown,
directoryListing: options.directoryListing,
});
for (let i = 0; i < options.path.length; i++) {

@@ -108,2 +107,6 @@ if (options.path[i].startsWith('/')) {

}
// disable directory listings by default
if (options.directoryListing === undefined) {
options.directoryListing = false;
}
// Ensure we do not mix http:// and file system paths. The paths passed in

@@ -195,35 +198,2 @@ // must all be filesystem paths, or HTTP paths.

/**
* Spin up a local HTTP server to serve static requests from disk
* @param root The local path that should be mounted as a static web server
* @param port The port on which to start the local web server
* @param markdown If markdown should be automatically compiled and served
* @private
* @returns Promise that resolves with the instance of the HTTP server
*/
async startWebServer(root, port, markdown) {
return new Promise((resolve, reject) => {
const serve = serveStatic(root);
const server = http
.createServer(async (req, res) => {
const pathParts = req.url.split('/').filter(x => !!x);
if (pathParts.length > 0) {
const ext = path.extname(pathParts[pathParts.length - 1]);
if (markdown && ext.toLowerCase() === '.md') {
const filePath = path.join(path.resolve(root), req.url);
const data = await readFile(filePath, { encoding: 'utf-8' });
const result = marked(data, { gfm: true });
res.writeHead(200, {
'content-type': 'text/html',
});
res.end(result);
return;
}
}
return serve(req, res, finalhandler(req, res));
})
.listen(port, () => resolve(server))
.on('error', reject);
});
}
/**
* Crawl a given url with the provided options.

@@ -230,0 +200,0 @@ * @pram opts List of options used to do the crawl

{
"name": "linkinator",
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.",
"version": "2.11.2",
"version": "2.12.0",
"license": "MIT",

@@ -26,3 +26,2 @@ "repository": "JustinBeckwith/linkinator",

"cheerio": "^1.0.0-rc.2",
"finalhandler": "^1.1.2",
"gaxios": "^4.0.0",

@@ -34,3 +33,3 @@ "glob": "^7.1.6",

"p-queue": "^6.2.1",
"serve-static": "^1.14.1",
"serve-handler": "^6.1.3",
"server-destroy": "^1.0.1",

@@ -42,3 +41,2 @@ "update-notifier": "^5.0.0"

"@types/cheerio": "0.22.22",
"@types/finalhandler": "^1.1.0",
"@types/glob": "^7.1.3",

@@ -49,3 +47,3 @@ "@types/marked": "^1.2.0",

"@types/node": "^12.7.12",
"@types/serve-static": "^1.13.8",
"@types/serve-handler": "^6.1.0",
"@types/server-destroy": "^1.0.0",

@@ -52,0 +50,0 @@ "@types/sinon": "^9.0.0",

@@ -48,2 +48,6 @@ # 🐿 linkinator

--directory-listing
Include an automatic directory index file when linking to a directory.
Defaults to 'false'.
--format, -f

@@ -142,2 +146,3 @@ Return the data in CSV or JSON format.

"markdown": true,
"directoryListing": true,
"skip": "www.googleapis.com"

@@ -166,2 +171,3 @@ }

- `linksToSkip` (array | function) - An array of regular expression strings that should be skipped, OR an async function that's called for each link with the link URL as its only argument. Return a Promise that resolves to `true` to skip the link or `false` to check it.
- `directoryListing` (boolean) - Automatically serve a static file listing page when serving a directory. Defaults to `false`.

@@ -168,0 +174,0 @@ #### linkinator.LinkChecker()

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc