New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

check-all-markdown

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-all-markdown - npm Package Compare versions

Comparing version 1.1.4 to 1.2.0

20

index.js

@@ -44,3 +44,7 @@ 'use strict'

exports.checkLink = (dir/*:string*/, link/*:string*/, {httpMethod = 'HEAD'}/*:{httpMethod: 'HEAD'|'GET'}*/ = {}) => {
exports.checkLink = (
basedir/*:string*/,
fileLinkIsIn/*:string*/,
link/*:string*/,
{httpMethod = 'HEAD'}/*:{httpMethod: 'HEAD'|'GET'}*/ = {}) => {
const linkUrl = url.parse(link)

@@ -55,4 +59,4 @@

? Promise.reject(new Error(`Broken link ${link}`))
: res.statusCode === 403 && httpMethod === 'HEAD'
? exports.checkLink(dir, link, {httpMethod: 'GET'})
: httpMethod === 'HEAD'
? exports.checkLink(basedir, fileLinkIsIn, link, {httpMethod: 'GET'})
: Promise.reject(new Error(`Could not fetch ${link}. status = ${res.statusCode}, method = ${httpMethod}`)))

@@ -62,9 +66,11 @@ } else if (!linkUrl.protocol && !/^[a-z.-]+@[a-z.-]+:/.test(link)) {

.then(() => {
const normalizedPath = link.startsWith('/') ? link.slice(1) : link
const normalizedPath = link.startsWith('/')
? path.resolve(basedir, link.slice(1))
: path.resolve(basedir, path.dirname(fileLinkIsIn), link)
return Promise.promisify(fs.stat)(path.join(dir, normalizedPath))
return Promise.promisify(fs.stat)(normalizedPath)
})
.then(() => true)
.catch(err => err.code === 'ENOENT'
? Promise.reject(new Error(`File ${link} not found in ${dir}`))
? Promise.reject(new Error(`File ${link} not found in ${fileLinkIsIn}`))
: err)

@@ -85,3 +91,3 @@ } else {

return Promise.all(links.map(link =>
exports.checkLink(dir, link)
exports.checkLink(dir, file, link)
.then(result => null)

@@ -88,0 +94,0 @@ .catch(err => err && Promise.resolve(`${file}: ${link} is broken`))))

{
"name": "check-all-markdown",
"version": "1.1.4",
"version": "1.2.0",
"description": "Checks all markdown files using markdownlint, and checks for broken links",

@@ -5,0 +5,0 @@ "main": "index.js",

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