markdown-link-check icon indicating copy to clipboard operation
markdown-link-check copied to clipboard

Error validating link in 3.10.0

Open jasonyavorsky opened this issue 3 years ago • 0 comments

I updated from 3.8.7 to 3.8.10, and now I get an error when my markdown contains:

![Buy](https://storage.googleapis.com/sourcegraph-assets/Vendr%20-%20Buy%20%231.jpg)

The script works as follows:

    const results = await checkMarkdownLinks(content, {
        baseUrl: pathToFileURL(path.dirname(absoluteFilePath)).href,
        ignorePatterns: [
            {
                // Ignore external links as they would cause irreproducable builds
                // Exception: our Google Cloud Storage URLs, as only admins are allowed to delete files so the chance of builds breaking is low.
                pattern:
                    /^https?:\/\/(?!(cors-anywhere.sgdev.org\/https?:\/\/)?sourcegraphstatic.com\/|storage.googleapis.com\/sourcegraph-assets\/)/,
            },
        ],
    })

I receive the following errror:

node:internal/streams/writable:312
      throw new ERR_INVALID_ARG_TYPE(
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at new NodeError (node:internal/errors:371:5)
    at _write (node:internal/streams/writable:312:13)
    at BlackHole.Writable.write (node:internal/streams/writable:334:10)
    at PassThrough.ondata (node:internal/streams/readable:754:22)
    at PassThrough.emit (node:events:390:28)
    at PassThrough.Readable.read (node:internal/streams/readable:527:10)
    at PassThrough.<anonymous> (/Users/jason/code/handbook/node_modules/needle/lib/needle.js:711:32)
    at PassThrough.emit (node:events:390:28)
    at emitReadable_ (node:internal/streams/readable:578:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This seems to only occur in 3.10.0. I suspect it has something to do with the ignore pattern, rather than the escape characters in the URL.

jasonyavorsky avatar Mar 21 '22 09:03 jasonyavorsky