tcort / markdown-link-check

checks all of the hyperlinks in a markdown text to determine if they are alive or dead
ISC License
583 stars 117 forks source link

Nested links lint triggers error with Node.js but not with npx #272

Open yoriiis opened 1 year ago

yoriiis commented 1 year ago

Using markdown-link-check through Node.js triggers an error while using through npx does not.


With the following files

README.md

# Title

[nested content](./docs/README.md)

docs/README.md

# Nested doc

With the npx command, it works.

npx markdown-link-check README.md

With Node.js it does not works.

node lint.js

lint.js

const fs = require('fs');
const markdownLinkCheck = require('markdown-link-check');

fs.readFile('README.md', 'utf8', (err, data) => {
    if (err) {
        console.error(err);
        return;
    }

    markdownLinkCheck(data, function (err, results) {
        if (err) {
            console.error('Error', err);
            return;
        }
        results.forEach(function (result) {
            console.log('%s is %s', result.link, result.status);
        });
    });
});

The following error appears:

node:internal/url:560
      throw new ERR_INVALID_URL(input);
      ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:399:5)
    at new URL (node:internal/url:560:13)
    at linkCheck (/Users/xxx/demo/node_modules/link-check/index.js:21:47)
    at /Users/xxx/demo/node_modules/markdown-link-check/index.js:119:9
    at /Users/xxx/demo/node_modules/async/dist/async.js:246:13
    at replenish (/Users/xxx/demo/node_modules/async/dist/async.js:446:21)
    at /Users/xxx/demo/node_modules/async/dist/async.js:451:13
    at _asyncMap (/Users/xxx/demo/node_modules/async/dist/async.js:244:16)
    at Object.mapLimit (/Users/xxx/demo/node_modules/async/dist/async.js:2091:16)
    at Object.awaitable [as mapLimit] (/Users/xxx/demo/node_modules/async/dist/async.js:211:32) {
  input: './docs/README.md',
  code: 'ERR_INVALID_URL'
}

The error is trigger with the following line on link-check.

yoriiis commented 7 months ago

@tcort Could you look at this issue please? Thanks

yoriiis commented 2 months ago

Hello, any hope on this please?

yoriiis commented 2 weeks ago

@tcort @nschonni sorry to interrupt, how can we help about this please? Thank you