Discord.js: escapeMarkdown breaks URLs when they contain underscores

Created on 14 Jun 2020  Â·  5Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:

escapeMarkdown escapes underscores which breaks URLs containing them.

Include a reproducible code sample here, if possible:

console.log(Discord.escapeMarkdown('https://www.youtube.com/watch?v=l03_BnPRIKc'))
console.log(Discord.escapeMarkdown('https://en.wikipedia.org/wiki/Orthoclydon_pseudostinaria#Conservation_status'))
console.log(Discord.escapeMarkdown('https://www.reddit.com/r/ManjaroLinux/comments/h8en59/its_rmanjarolinuxs_7th_birthday_yay_us/'))
https://www.youtube.com/watch?v=l03\_BnPRIKc
https://en.wikipedia.org/wiki/Orthoclydon\_pseudostinaria#Conservation\_status
https://www.reddit.com/r/ManjaroLinux/comments/h8en59/its\_rmanjarolinuxs\_7th\_birthday\_yay\_us/

Further details:

  • discord.js version: 12.2.0
  • Node.js version: 14.4.0
  • Operating system: Ubuntu 18.04
  • Priority this issue should have – please be realistic and elaborate if possible: Low / Medium
  • [ ] I have also tested the issue on latest master, commit hash:
unverified utility bug

All 5 comments

I think Discord client recently fixed this. URLs in Discord previously used to not take underscores into account and would italicize it, but it doesn't appear to be a problem anymore

is this still a problem? if so, i can have a look at it and submit a PR for my solution

@puf17640 I just updated Discord.js and tried again, the bug is still there. I'm on master.

@puf17640 I just updated Discord.js and tried again, the bug is still there. I'm on master.

alright, I will have a look when I find the time today!

So I just wasted around 1-2 hours on trying to fix this, but it's a pain in the ass given how the escaping code is written. From how it is done now, it is (in my opinion) nearly impossible to fix this without breaking something else and I currently do not have enough time to assure that I won't break anything else with my fix.
I'm sorry @ManuelFte

Was this page helpful?
0 / 5 - 0 ratings