parser icon indicating copy to clipboard operation
parser copied to clipboard

Option to convert relative links to absolute

Open matthewpwatkins opened this issue 5 years ago • 0 comments

  • Platform: Linux
  • Mercury Parser Version: 2.2.0
  • Node Version (if a Node bug): 8.x

Current Behavior

Suppose I call the parser and pass in the URL of an article with relative links. For example, I'm calling the parser for a page on churchofjesuschrist.org and getting back unqualified links in the text like this:

See <a href="/study/scriptures/nt/matt/25">Matthew 25</a> for more details...

Right now, the parser returns the URLs exactly as they are specified on the source page-- as relative paths. The same to images and other content.

Expected Behavior

I would love to have the ability to pass in a command option that will fully-qualify all the URLs during render. Example desired output:

See <a href="https://www.churchofjesuschrist.org/study/scriptures/nt/matt/25">Matthew 25</a> for more details...

Currently I have to correct for these with Regex after parsing (fortunately I'm using Markdown mode so that's not too tricky at the moment).

Steps to Reproduce

  1. Call the parser for a web page with relative URLs in images, links, etc
  2. See the output preserves the relative URLs instead of fully qualifying them.

Possible Solution

It would be nice to have an option I can pass in to enable this feature

matthewpwatkins avatar Dec 17 '19 18:12 matthewpwatkins