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.5.0 to 2.5.1

51

build/src/index.js

@@ -6,4 +6,6 @@ "use strict";

const gaxios = require("gaxios");
const http = require("http");
const enableDestroy = require("server-destroy");
const express = require("express");
const finalhandler = require("finalhandler");
const serveStatic = require("serve-static");
const fs = require("fs");

@@ -130,5 +132,4 @@ const util = require("util");

options.path = [path.sep + pathParts[pathParts.length - 1]];
options.serverRoot = pathParts
.slice(0, pathParts.length - 1)
.join(path.sep);
options.serverRoot =
pathParts.slice(0, pathParts.length - 1).join(path.sep) || '.';
}

@@ -152,23 +153,25 @@ else {

async startWebServer(root, port, markdown) {
const app = express()
.use(async (req, res, next) => {
if (!markdown) {
return next();
}
const pathParts = req.path.split('/').filter(x => !!x);
const ext = path.extname(pathParts[pathParts.length - 1]);
if (ext.toLowerCase() === '.md') {
const filePath = path.join(path.resolve(root), req.path);
const data = await readFile(filePath, { encoding: 'utf-8' });
const result = marked(data, { gfm: true });
res.send(result).end();
return;
}
return next();
})
.use(express.static(path.resolve(root)));
const server = await new Promise(resolve => {
const s = app.listen(port, () => resolve(s));
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);
});
return server;
}

@@ -175,0 +178,0 @@ /**

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

@@ -24,3 +24,3 @@ "repository": "JustinBeckwith/linkinator",

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

@@ -31,2 +31,3 @@ "jsonexport": "^3.0.0",

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

@@ -38,3 +39,3 @@ "update-notifier": "^5.0.0"

"@types/cheerio": "^0.22.10",
"@types/express": "^4.17.9",
"@types/finalhandler": "^1.1.0",
"@types/marked": "^1.2.0",

@@ -44,2 +45,3 @@ "@types/meow": "^5.0.0",

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

@@ -46,0 +48,0 @@ "@types/sinon": "^9.0.0",

@@ -7,3 +7,2 @@ # 🐿 linkinator

[![codecov](https://codecov.io/gh/JustinBeckwith/linkinator/branch/master/graph/badge.svg)](https://codecov.io/gh/JustinBeckwith/linkinator)
[![Dependency Status](https://img.shields.io/david/JustinBeckwith/linkinator.svg)](https://david-dm.org/JustinBeckwith/linkinator)
[![Known Vulnerabilities](https://snyk.io/test/github/JustinBeckwith/linkinator/badge.svg)](https://snyk.io/test/github/JustinBeckwith/linkinator)

@@ -258,4 +257,7 @@ [![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)

## Using a proxy
This library supports proxies via the `HTTP_PROXY` and `HTTPS_PROXY` environment variables. This [guide](https://www.golinuxcloud.com/set-up-proxy-http-proxy-environment-variable/) provides a nice overview of how to format and set these variables.
## License
[MIT](LICENSE.md)

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