Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yoriiis opened this issue Jul 10, 2023 · 1 comment
Open

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

yoriiis opened this issue Jul 10, 2023 · 1 comment

Comments

@yoriiis
Copy link

yoriiis commented Jul 10, 2023

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
Copy link
Author

yoriiis commented Apr 2, 2024

@tcort Could you look at this issue please? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant