Skip to content

No link truncation in parse() function #426

@Khodunov

Description

@Khodunov

Description

Truncation works just fine, but the only place where I found the truncated text inside the match object was in match.buildTag().innerHTML, the link in .getAnchorText() isn't truncated.
Based on the source code, it happens because truncation is performed only inside the tagBulder, so in my case (I wanted to process matches manually, with custom safety checks) it wasn't performed at all.

Steps to reproduce

  1. const matches = Autolinker.parse("https://www.example.com/some-very-long-link/with/a/long/path", {truncate: 20});
  2. There is no truncated link inside the match object. The link inside match.buildTag().innerHTML requires substring replacement:
match.buildTag().innerHTML.replace("…", "...")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions