DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.
MIT License
4.83k stars 733 forks source link

`link-image-style` throws error with `<foo@example.com>` #1391

Closed regseb closed 3 weeks ago

regseb commented 3 weeks ago

Since 0.36.0, The link-image-style rule (MD054), with { "shortcut": false } or { "url_inline": false } option, throws an error when markdown has mail surround <> (e.g. <foo@example.com>, _CODE_OFCONDUCT.md):

/home/regseb/testcase/node_modules/markdownlint/lib/md054.js:54
        destination = getDescendantsByType(link, [ "autolinkProtocol" ])[0].text;
                                                                           ^

TypeError: Cannot read properties of undefined (reading 'text')
    at Object.function (/home/regseb/testcase/node_modules/markdownlint/lib/md054.js:54:76)
    at invokeRuleFunction (/home/regseb/testcase/node_modules/markdownlint/lib/markdownlint.js:665:51)
    at forRule (/home/regseb/testcase/node_modules/markdownlint/lib/markdownlint.js:676:7)
    at Array.map (<anonymous>)
    at lintContent (/home/regseb/testcase/node_modules/markdownlint/lib/markdownlint.js:743:44)
    at lintContentWrapper (/home/regseb/testcase/node_modules/markdownlint/lib/markdownlint.js:796:12)
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)

Node.js v22.10.0
DavidAnson commented 3 weeks ago

Thanks, I'll fix this tonight.