Skip to content

An anchor (<a/>) without a href attribute causes a crash #11

Closed
@AMKohn

Description

@AMKohn

Hi,

I have started developing with html-to-text and discovered that it expects every anchor to have a href and crashes when it doesn't find one.

Changing line 25 in formatter.js from

return elem.attribs.href.replace(/^mailto\:/, '');

to

if (elem.attribs && elem.attribs.href) {
    return elem.attribs.href.replace(/^mailto\:/, '');
}
else {
    return helper.wordwrap(helper.decodeHTMLEntities(_s.strip(elem.raw)), options.wordwrap);
}

fixes this.

Thank you!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions