Open link at cursor?

Trying to create a regex to reliably identify all of the possible variations of a URL is something that seems to have a lot of complexity and nuance to it.

Just take a look at this page, it has an awesome comparison table:

https://mathiasbynens.be/demo/url-regex

I had a bash at it myself last year, but while I managed seem pretty solid matching, it simply didn’t work for everything. That was the kicker for me. If it was for my own purposes, then I could probably have used one of the many existing regex solutions, and that would be fine. But, I wanted to share what I produced and so I decided that close was not close enough as someone was bound to run into an issue … and then I’d feel compelled to try and workaround it for a low occurrence case.

If it is just for you, or you don’t feel you would find yourself in this position, then I would suggest just selecting on of the expressions from the above page that meets the criteria you want it to work for.

In the end I just went simpler and stuck to creating something that works with Markdown and wiki-style links; basically because between the two that covered most links people used, was easy to match against, and could be defined discretely without dubious edge cases.

The result of that was I created the TAD-Process Link action in the ThoughtAsylum - Management action group. The action does the following.

Taking the start of any selection as the cursor location, this action will attempt to identify any Markdown or wiki-style cross-link that the cursor is within. The action will then process that link as though it was a link the user had manually activated. If you favour the keyboard as your primary Drafts interaction device, consider creating an action that calls this one and assign it a keyboard shortcut.

Hopefully something above will get you where you want to go, or stop you spending as many days (I think I spent over 30 hours looking at this) time tweaking regex patterns as I did to try and eke out more edge case matches.