linkinator
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60472
786
262
11
21
1
+ Addedfinalhandler@^1.1.2
+ Addedserve-static@^1.14.1
- Removedexpress@^4.17.1
- Removedaccepts@1.3.8(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedexpress@4.21.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedobject-inspect@1.13.2(transitive)
- Removedpath-to-regexp@0.1.10(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)