Skip to content

Conversation

@kemsakurai
Copy link
Contributor

When applying textlint-rule-no-dead-link to HTML, an error occurred.

`console ✖ Stack trace TypeError: Parameter "url" must be a string, not undefined at Url.parse (url.js: 102: 11) at Object.urlParse [as parse] (url.js: 96: 5) at isRelative (/usr/local/lib/node_modules/textlint-rule-no-dead-link/lib/no-dead-link .js:83:24) at /usr/local/lib/node_modules/textlint-rule-no-dead-link/lib/no-dead-link. js: 107: 11 at Generator.next (<anonymous>) `

textlint-rule-no-dead-link expects the Link Node to hold the url
property, and in the case of txt, markdown it holds the actual url
property.
I think that the Link Node generated from the html file should also
keep the url property. [^ 1]

[1]: The href attribute of a tag is not mandatory.
If href does not exist, url is not set.
If url does not exist, a fix to ignore the target Link node is required to textlint-rule-no-dead-link.

When applying `textlint-rule-no-dead-link` to HTML, an error occurred.

`` `console
✖ Stack trace
TypeError: Parameter "url" must be a string, not undefined
    at Url.parse (url.js: 102: 11)
    at Object.urlParse [as parse] (url.js: 96: 5)
    at isRelative
(/usr/local/lib/node_modules/textlint-rule-no-dead-link/lib/no-dead-link
.js:83:24)
    at
/usr/local/lib/node_modules/textlint-rule-no-dead-link/lib/no-dead-link.
js: 107: 11
    at Generator.next (<anonymous>)
`` `

textlint-rule-no-dead-link expects the Link Node to hold the url
property, and in the case of txt, markdown it holds the actual url
property.
I think that the Link Node generated from the html file should also
keep the url property. [^ 1]

[1]: The href attribute of `a` tag is not mandatory.
If href does not exist, url is not set.
If url does not exist, a fix to ignore the target Link node is required
for `textlint-rule-no-dead-link`.
node.raw = html.slice(range[0], range[1]);
}
// map `url` to Link node
if (node.type === "Link" && node.properties.href !== "undefined") {
Copy link
Member

@azu azu Nov 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.properties.href !== "undefined"

typeof node.properties.href !== "undefined" ?

Can you add a test-case for <a>text</a> pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I'll fix it.

@azu azu added the Type: Bug Bug or Bug fixes label Nov 19, 2017
Fix undefined check of href, and add test for placeholder.
@azu
Copy link
Member

azu commented Nov 19, 2017

LTGM. Thanks for fixing.

@azu azu merged commit 5736b2a into textlint:master Nov 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants