Closed gdog2u closed 2 years ago
The following line in writeAnchorTag()
is responsible for changing url
by the time I was accessing it.
url = url.replace(showdown.helper.regexes.asteriskDashTildeAndColon, showdown.helper.escapeCharactersCallback);
Added variable to store a clean copy of the url.
I am working on a PR that modifies the way links are parsed. A part of this requires checking the link's destination domain against the current domain. To do this, I am trying to using
showdown.helper.URLUtils
to parse theurl
value inLinks.js > writeAnchorTag
. After much time troubleshooting, I am seeing thathost
andhostname
keep coming back empty.Relevant code:
As a means of debugging, I set the script to print
pathname
, and found that the whole link is being passed through there. Below is the result ofattributes.rel = urlMeta.pathname
Of note, when I copy/paste the
showdown.helper.URLUtils
, (e.g.showdown.helper.URLUtils('https://google.com')
) function into the browser console, and try running it there, I get the expected results.Edit: Troubleshooting has shown that this is most likely because the parser performing some sanitation at this point.
https://
becomeshttps¨E58E//
This disallows URLUtils to properly parse the url.