I tried to reproduce the issue in autolink_test.go in the mattermost server project, but it does the right thing for this example (the result of parseAutolink did include the brace).
Interesting find. I would’ve said that it’s just a bug in marked.js, but it also occurs with the custom autolinking we’ve added to commonmark.js in the mobile app as well. I’m actually surprised the server’s Markdown parser handles it correctly, but I’m pretty sure that I just translated that code from GitHub’s Markdown parser instead of trying to write a completely custom version like the apps use.
I spent a bit of time comparing the code used on the server with our custom marked and commonmark versions, and it looks like the difference is that the apps treat curly brackets, as well as some other characters, as punctuation that should be trimmed from the end of the link, while the server does not. Fixing that should actually be fairly easy in that case, since I expected it to be caused by something more complicated. Great catch that the server handles it correctly or else we might not have noticed that.
I’ve filed MM-13837 to look into this further. Also, since you were comfortable digging around in the markdown parser on the server, I can gladly point you into the right direction if you’d like to help out by fixing it on the web and mobile apps.
Thanks @hmhealey. I have almost zero JavaScript knowledge right now so I doubt I will be much use on the webapp side but maybe I will take a look one weekend…