I don't think there's a practical solution to this since the context is a user message which can contain an unequal number of brackets and the url itself could contain an unequal number of brackets.

We could assume that all user messages and urls contain an equal number of opening and closing brackets - this would however break in any message that doesn't fit this assumption.

I'll see if I can tweak the behaviour a little bit.