Skip to content

Bug: getUrl method not working correctly for links in markdown formats #383

@saurabhLearns

Description

@saurabhLearns

Hey,

I've been messing with autolinker and found this strange behavior (not sure if this is expected or not, but looks like a bug in first place)

Adding a small snippet which is already tried and tested on runkit as well.

let autolinker = require("autolinker");

let inputText = 'If I add this sample link which is in the markdown format [https://example.com/productdetails.aspx?productid=9999](https://example.com/productdetails.aspx?productid=9999), getUrl method does not correctly works. but if I do this same with this [https://linkedin.com](https://linkedin.com) it works perfectly)'

autolinker.link(inputText, {
      replaceFn: (match) => {
        if (match.getType() == 'url') {
          const matchedUrl = match.getUrl();
          console.log(matchedUrl)
        }
      }
    });

Expected Output

https://example.com/productdetails.aspx?productid=9999
https://linkedin.com

Actual Output

https://example.com/productdetails.aspx?productid=9999](https://example.com/productdetails.aspx?productid=9999)
https://linkedin.com

Snippet from runkit:
Screenshot 2022-08-08 at 3 10 37 PM

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